[VB.NET] Twitter Library


Deskripsi
    This is my first library that can connect API twitter, very simple but not accomodate all API.
Release Date :
11-10-2013 *ver: 1.0.0.0

Api Support (Api Version : 1.1):
- For data retrieval
GET statuses/mentions_timeline *tested
GET statuses/user_timeline *tested
GET statuses/home_timeline *tested
GET statuses/retweets_of_me  *not tested

- For posting tweets
POST statuses/update *tested

Required : .NET Framework 4
Download Here : TwitterLib

*Note : - if success it will return JSON (for data retrieval), tweet posting not return JSON
             - Data retrieval limited 15 request / 15 minutes (it's policy from twitter, if you flood the request your account will be blacklist permanently so use wisely !!)

Howto
1. before use this library make sure you already have account twitter and login at dev.twitter.com
2. create new application (to open just click your avatar and select new application)
3. after you create application you get 4 key :
     - consumer key
     - consumer secret
     - access token  *status readonly
     - access token secret *status readonly
4. if you want to posting tweets , you must setting access token to "read , write" you can change by click SETTINGS (in you application that you create) select application type , after that click update setting and back  to menu DETAILS click Recreate my access token then you will get new access token and access token secret.
5. save this 4 key in notepad , we will use this in my library.

this library i test in VB.NET , i don't sure if use in VB6 or another programming language.

Add refference Library : - Project > Add Refference
                                      - Import in your project : Imports TwitterLib

Here's the syntax :
------------------------------------------------------------------------------------------------------------
* For posting tweets
        Dim json As String
        Dim objtwitter As New TwitterLib.TwitterLib
        objtwitter.chooseWorkType = 1 ' 0 for retrieval , 1 for updatestatus
        objtwitter.chooseMethod = 1 ' 0 for get(data retrieval) , 1 for post(Post tweets) ' see REST API 1.1 !
        objtwitter.updateStatus = "My First Tweets using Api"
        objtwitter.oauth_consumer_key = "XXX"
        objtwitter.oauth_consumer_secret = "YYY"
        objtwitter.oauth_token = "ZZZZ"
        objtwitter.oauth_token_secret = "AAAA"
        objtwitter.oauth_resource_url = "https://api.twitter.com/1.1/statuses/update.json" 'see my description
        json = objtwitter.Connect_Api_Twitter()
        System.Diagnostics.Debug.Write(json) 'normally posting doesnt return json


-----------------------------------------------------------------------------------------------------------
* For Data Retrieval
        Dim json As String
        Dim objtwitter As New TwitterLib.TwitterLib
        objtwitter.chooseMethod = 0 ' 0 for get , 1 for post
        objtwitter.chooseWorkType = 0 ' 0 for retrieval , 1 for updatestatus
        objtwitter.count = 10
        objtwitter.oauth_consumer_key = "xxxx"
        objtwitter.oauth_consumer_secret = "yyyy
        objtwitter.oauth_token = "aaaa"
        objtwitter.oauth_token_secret = "zzzzz"
        objtwitter.oauth_resource_url = "https://api.twitter.com/1.1/statuses/user_timeline.json" 'see my description
        json = objtwitter.Connect_Api_Twitter()
        messagebox.show(json)
        MessageBox.Show("limitation Request: " & objtwitter.limitation)
        MessageBox.Show("limitation Use : " & objtwitter.rate_limit)

after get JSON , you must still parser manually.

if error occured / bug / question , please comment in bottom ....  thank you :D

Post a Comment

Harap gunakan bahasa yang baik dan sopan, terima kasih