Click here to Skip to main content
15,881,757 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am not getting tweets when I call makeRequest()
I am getting following result

[{"created_at":"Mon Mar 21 18:05:13 +0000 2016","id":711976973719867393,"id_str":"711976973719867393","text":"My twitter test2","entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[]},"truncated":false,"source":"\u003ca href=\"https:\/\/twitter.com\/sgramesh75\" rel=\"nofollow\"\u003eshjtweet2\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":1070473861,"id_str":"1070473861","name":"ramesh sunderasan","screen_name":"sgramesh75","location":"Sharjah, United Arab Emirates","description":"","url":"https:\/\/t.co\/OSutcvafot","entities":{"url":{"urls":[{"url":"https:\/\/t.co\/OSutcvafot","expanded_url":"https:\/\/twitter.com\/sharjahtv","display_url":"twitter.com\/sgramesh75","indices":[0,23]}]},"description":{"urls":[]}},"protected":false,"followers_count":5,"friends_count":2,"listed_count":0,"created_at":"Tue Jan 08 09:43:26 +0000 2013","favourites_count":0,"utc_offset":null,"time_zone":null,"geo_enabled":false,"verified":false,"statuses_count":3,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_image_url":"http:\/\/abs.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","profile_image_url_https":"https:\/\/abs.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":true,"default_profile":true,"default_profile_image":true,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":0,"favorite_count":0,"favorited":false,"retweeted":false,"lang":"en"},{"created_at":"Mon Mar 21 18:01:01 +0000 2016","id":711975919431200768,"id_str":"711975919431200768","text":"My twitter test","entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[]},"truncated":false,"source":"\u003ca href=\"https:\/\/twitter.com\/sharjahnews\" rel=\"nofollow\"\u003eshjtweet2\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":1070473861,"id_str":"1070473861","name":"ramesh sunderasan","screen_name":"sgramesh75","location":"Sharjah, United Arab Emirates","description":"","url":"https:\/\/t.co\/OSutcvafot","entities":{"url":{"urls":[{"url":"https:\/\/t.co\/OSutcvafot","expanded_url":"https:\/\/twitter.com\/sharjahtv","display_url":"twitter.com\/sharjahtv","indices":[0,23]}]},"description":{"urls":[]}},"protected":false,"followers_count":5,"friends_count":2,"listed_count":0,"created_at":"Tue Jan 08 09:43:26 +0000 2013","favourites_count":0,"utc_offset":null,"time_zone":null,"geo_enabled":false,"verified":false,"statuses_count":3,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_image_url":"http:\/\/abs.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","profile_image_url_https":"https:\/\/abs.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":true,"default_profile":true,"default_profile_image":true,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":0,"favorite_count":0,"favorited":false,"retweeted":false,"lang":"en"},{"created_at":"Fri Jul 12 14:05:30 +0000 2013","id":355689377319485442,"id_str":"355689377319485442","text":"ARE YOU READY to hear about the newest trick in shredding so much extra off... ASAP? http:\/\/t.co\/jxINV2tAH6","entities":{"hashtags":[],"symbols":[],"user_mentions":[],"urls":[{"url":"http:\/\/t.co\/jxINV2tAH6","expanded_url":"http:\/\/WOMENHEALTHBLOG.COM-new.net\/july?narshkcjpy","display_url":"WOMENHEALTHBLOG.COM-new.net\/july?narshkcjpy","indices":[85,107]}]},"truncated":false,"source":"\u003ca href=\"http:\/\/twitter.com\" rel=\"nofollow\"\u003eTwitter Web Client\u003c\/a\u003e","in_reply_to_status_id":null,"in_reply_to_status_id_str":null,"in_reply_to_user_id":null,"in_reply_to_user_id_str":null,"in_reply_to_screen_name":null,"user":{"id":1070473861,"id_str":"1070473861","name":"ramesh sunderasan","screen_name":"sgramesh75","location":"Sharjah, United Arab Emirates","description":"","url":"https:\/\/t.co\/OSutcvafot","entities":{"url":{"urls":[{"url":"https:\/\/t.co\/OSutcvafot","expanded_url":"https:\/\/twitter.com\/sharjahtv","display_url":"twitter.com\/sharjahtv","indices":[0,23]}]},"description":{"urls":[]}},"protected":false,"followers_count":5,"friends_count":2,"listed_count":0,"created_at":"Tue Jan 08 09:43:26 +0000 2013","favourites_count":0,"utc_offset":null,"time_zone":null,"geo_enabled":false,"verified":false,"statuses_count":3,"lang":"en","contributors_enabled":false,"is_translator":false,"is_translation_enabled":false,"profile_background_color":"C0DEED","profile_background_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme1\/bg.png","profile_background_tile":false,"profile_image_url":"http:\/\/abs.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","profile_image_url_https":"https:\/\/abs.twimg.com\/sticky\/default_profile_images\/default_profile_2_normal.png","profile_link_color":"0084B4","profile_sidebar_border_color":"C0DEED","profile_sidebar_fill_color":"DDEEF6","profile_text_color":"333333","profile_use_background_image":true,"has_extended_profile":true,"default_profile":true,"default_profile_image":true,"following":false,"follow_request_sent":false,"notifications":false},"geo":null,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_count":0,"favorite_count":0,"favorited":false,"retweeted":false,"possibly_sensitive":false,"lang":"en"}]


What I have tried:

VB
Public Function makeRequest(ByVal query As String)
        Dim requestResult As String = ""
        oauth_nonce = setNounce()
        oauth_timestamp = setTimeStamp()
        Dim oauth_signature As String = getSignature(oauth_consumer_key, oauth_nonce, oauth_timestamp, oauth_token, consumer_secret, oauth_token_secret, query)


        'Set the authorization header
        Dim headerFormat As String = "OAuth oauth_nonce=""{0}"", oauth_signature_method=""{1}"", oauth_timestamp=""{2}"", oauth_consumer_key=""{3}"", oauth_token=""{4}"", oauth_signature=""{5}"", oauth_version=""{6}"""
        Dim authHeader As String = String.Format(headerFormat, Uri.EscapeDataString(oauth_nonce), Uri.EscapeDataString(oauth_signature_method), Uri.EscapeDataString(oauth_timestamp), Uri.EscapeDataString(oauth_consumer_key), Uri.EscapeDataString(oauth_token), Uri.EscapeDataString(oauth_signature), Uri.EscapeDataString(oauth_version))


        'set the request
        ServicePointManager.Expect100Continue = False
        Dim request As WebRequest
        Dim response As HttpWebResponse
        Dim streamReader As System.IO.StreamReader
        Dim encode As Encoding = System.Text.Encoding.GetEncoding("utf-8")
        request = WebRequest.Create(requestUrl & "?" & reqParam(query))
        request.Timeout = -1
        request .Headers.Add("Authorization", authHeader)

        Try
            response = DirectCast(request.GetResponse(), HttpWebResponse)
            streamReader = New System.IO.StreamReader(response.GetResponseStream(), True)
            requestResult = streamReader.ReadLine()
            request.Abort()
            streamReader.Close()
            streamReader = Nothing
            response.Close()
            response = Nothing
        Catch ex As Exception
            MsgBox(ex.Message, MsgBoxStyle.Critical)
        End Try

        Return requestResult
    End Function
Posted
Updated 2-May-16 3:19am
v3
Comments
Garth J Lancaster 2-May-16 8:38am    
well, you're getting something (not an error) - thats a start ... what that code doesnt show us is the query you're passing into makeRequest - please edit your question to supply that
Member 12480796 3-May-16 2:07am    
Dim myReq As New userRequest(oauth_consumer_key, consumer_secret, oauth_token, oauth_token_secret)

Dim response As String = myReq.makeRequest(screen Name)

Class userRequest()
Private requestUrl As String = "https://api.twitter.com/1.1/statuses/user_timeline.json"
Private requestMethod As String = "GET"
Private oauth_version As String = "1.0"
Private oauth_signature_method As String = "HMAC-SHA1"
Garth J Lancaster 3-May-16 3:41am    
you need to learn

1) how to read JSON - its correct, and as pointed out below, there are 3 tweets in that return
2) how to read the documentation https://dev.twitter.com/rest/reference/get/statuses/user_timeline

you could try

Private requestUrl As String = "https://api.twitter.com/1.1/statuses/user_timeline.json?count=25?include_rts=false"

for example
Member 12480796 3-May-16 6:02am    
iam getting 401 unauthorized

Private requestUrl As String = "https://api.twitter.com/1.1/statuses/user_timeline.json?count=25?include_rts=false"
Garth J Lancaster 3-May-16 6:55am    
there's not enough information shown to see what your authentication issue is - have a look here http://www.codeproject.com/Articles/729577/API-Talk-to-Twitter-API-Via-Csharp-part for example and see if you're setting the same types of values

1 solution

What you are receiving called JSON...it looks like this when formatted:
JavaScript
[
  {
    "created_at": "Mon Mar 21 18:05:13 +0000 2016",
    "id": 711976973719867400,
    "id_str": "711976973719867393",
    "text": "My twitter test2",
    "entities": {
      "hashtags": [],
      "symbols": [],
      "user_mentions": [],
      "urls": []
    },
    "truncated": false,
    "source": "<a href=\"https://twitter.com/sgramesh75\" rel=\"nofollow\">shjtweet2</a>",
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "in_reply_to_screen_name": null,
    "user": {
      "id": 1070473861,
      "id_str": "1070473861",
      "name": "ramesh sunderasan",
      "screen_name": "sgramesh75",
      "location": "Sharjah, United Arab Emirates",
      "description": "",
      "url": "https://t.co/OSutcvafot",
      "entities": {
        "url": {
          "urls": [
            {
              "url": "https://t.co/OSutcvafot",
              "expanded_url": "https://twitter.com/sharjahtv",
              "display_url": "twitter.com/sgramesh75",
              "indices": [
                0,
                23
              ]
            }
          ]
        },
        "description": {
          "urls": []
        }
      },
      "protected": false,
      "followers_count": 5,
      "friends_count": 2,
      "listed_count": 0,
      "created_at": "Tue Jan 08 09:43:26 +0000 2013",
      "favourites_count": 0,
      "utc_offset": null,
      "time_zone": null,
      "geo_enabled": false,
      "verified": false,
      "statuses_count": 3,
      "lang": "en",
      "contributors_enabled": false,
      "is_translator": false,
      "is_translation_enabled": false,
      "profile_background_color": "C0DEED",
      "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
      "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
      "profile_background_tile": false,
      "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png",
      "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png",
      "profile_link_color": "0084B4",
      "profile_sidebar_border_color": "C0DEED",
      "profile_sidebar_fill_color": "DDEEF6",
      "profile_text_color": "333333",
      "profile_use_background_image": true,
      "has_extended_profile": true,
      "default_profile": true,
      "default_profile_image": true,
      "following": false,
      "follow_request_sent": false,
      "notifications": false
    },
    "geo": null,
    "coordinates": null,
    "place": null,
    "contributors": null,
    "is_quote_status": false,
    "retweet_count": 0,
    "favorite_count": 0,
    "favorited": false,
    "retweeted": false,
    "lang": "en"
  },
  {
    "created_at": "Mon Mar 21 18:01:01 +0000 2016",
    "id": 711975919431200800,
    "id_str": "711975919431200768",
    "text": "My twitter test",
    "entities": {
      "hashtags": [],
      "symbols": [],
      "user_mentions": [],
      "urls": []
    },
    "truncated": false,
    "source": "<a href=\"https://twitter.com/sharjahnews\" rel=\"nofollow\">shjtweet2</a>",
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "in_reply_to_screen_name": null,
    "user": {
      "id": 1070473861,
      "id_str": "1070473861",
      "name": "ramesh sunderasan",
      "screen_name": "sgramesh75",
      "location": "Sharjah, United Arab Emirates",
      "description": "",
      "url": "https://t.co/OSutcvafot",
      "entities": {
        "url": {
          "urls": [
            {
              "url": "https://t.co/OSutcvafot",
              "expanded_url": "https://twitter.com/sharjahtv",
              "display_url": "twitter.com/sharjahtv",
              "indices": [
                0,
                23
              ]
            }
          ]
        },
        "description": {
          "urls": []
        }
      },
      "protected": false,
      "followers_count": 5,
      "friends_count": 2,
      "listed_count": 0,
      "created_at": "Tue Jan 08 09:43:26 +0000 2013",
      "favourites_count": 0,
      "utc_offset": null,
      "time_zone": null,
      "geo_enabled": false,
      "verified": false,
      "statuses_count": 3,
      "lang": "en",
      "contributors_enabled": false,
      "is_translator": false,
      "is_translation_enabled": false,
      "profile_background_color": "C0DEED",
      "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
      "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
      "profile_background_tile": false,
      "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png",
      "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png",
      "profile_link_color": "0084B4",
      "profile_sidebar_border_color": "C0DEED",
      "profile_sidebar_fill_color": "DDEEF6",
      "profile_text_color": "333333",
      "profile_use_background_image": true,
      "has_extended_profile": true,
      "default_profile": true,
      "default_profile_image": true,
      "following": false,
      "follow_request_sent": false,
      "notifications": false
    },
    "geo": null,
    "coordinates": null,
    "place": null,
    "contributors": null,
    "is_quote_status": false,
    "retweet_count": 0,
    "favorite_count": 0,
    "favorited": false,
    "retweeted": false,
    "lang": "en"
  },
  {
    "created_at": "Fri Jul 12 14:05:30 +0000 2013",
    "id": 355689377319485440,
    "id_str": "355689377319485442",
    "text": "ARE YOU READY to hear about the newest trick in shredding so much extra off... ASAP? http://t.co/jxINV2tAH6",
    "entities": {
      "hashtags": [],
      "symbols": [],
      "user_mentions": [],
      "urls": [
        {
          "url": "http://t.co/jxINV2tAH6",
          "expanded_url": "http://WOMENHEALTHBLOG.COM-new.net/july?narshkcjpy",
          "display_url": "WOMENHEALTHBLOG.COM-new.net/july?narshkcjpy",
          "indices": [
            85,
            107
          ]
        }
      ]
    },
    "truncated": false,
    "source": "<a href=\"http://twitter.com\" rel=\"nofollow\">Twitter Web Client</a>",
    "in_reply_to_status_id": null,
    "in_reply_to_status_id_str": null,
    "in_reply_to_user_id": null,
    "in_reply_to_user_id_str": null,
    "in_reply_to_screen_name": null,
    "user": {
      "id": 1070473861,
      "id_str": "1070473861",
      "name": "ramesh sunderasan",
      "screen_name": "sgramesh75",
      "location": "Sharjah, United Arab Emirates",
      "description": "",
      "url": "https://t.co/OSutcvafot",
      "entities": {
        "url": {
          "urls": [
            {
              "url": "https://t.co/OSutcvafot",
              "expanded_url": "https://twitter.com/sharjahtv",
              "display_url": "twitter.com/sharjahtv",
              "indices": [
                0,
                23
              ]
            }
          ]
        },
        "description": {
          "urls": []
        }
      },
      "protected": false,
      "followers_count": 5,
      "friends_count": 2,
      "listed_count": 0,
      "created_at": "Tue Jan 08 09:43:26 +0000 2013",
      "favourites_count": 0,
      "utc_offset": null,
      "time_zone": null,
      "geo_enabled": false,
      "verified": false,
      "statuses_count": 3,
      "lang": "en",
      "contributors_enabled": false,
      "is_translator": false,
      "is_translation_enabled": false,
      "profile_background_color": "C0DEED",
      "profile_background_image_url": "http://abs.twimg.com/images/themes/theme1/bg.png",
      "profile_background_image_url_https": "https://abs.twimg.com/images/themes/theme1/bg.png",
      "profile_background_tile": false,
      "profile_image_url": "http://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png",
      "profile_image_url_https": "https://abs.twimg.com/sticky/default_profile_images/default_profile_2_normal.png",
      "profile_link_color": "0084B4",
      "profile_sidebar_border_color": "C0DEED",
      "profile_sidebar_fill_color": "DDEEF6",
      "profile_text_color": "333333",
      "profile_use_background_image": true,
      "has_extended_profile": true,
      "default_profile": true,
      "default_profile_image": true,
      "following": false,
      "follow_request_sent": false,
      "notifications": false
    },
    "geo": null,
    "coordinates": null,
    "place": null,
    "contributors": null,
    "is_quote_status": false,
    "retweet_count": 0,
    "favorite_count": 0,
    "favorited": false,
    "retweeted": false,
    "possibly_sensitive": false,
    "lang": "en"
  }
]

It is actually an array of 3 tweets...To learn about the inner structure of each tweet, you should go to the documentation: Documentation | Twitter Developers[^]
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 2-May-16 9:45am    
5ed.
—SA
Kornfeld Eliyahu Peter 2-May-16 10:24am    
Thank you!
Member 12480796 3-May-16 2:27am    
Thank You
i looked into twitter document, but iam not getting how to read all tweets in vb.net..
Garth J Lancaster 3-May-16 3:47am    
I would take the JSON, and build a schema from it, then deserialize the JSON return to the class structure - then its easy - unfortunately, I dont know enough VB.Net to do it

in c# I start with http://json2csharp.com/ - it cant be hard to go from c# classes to vb.net classes - then its one call

JsonConvert.DeserializeObject(Of <The Class object>)(<json string="">)

to populate the schema/class objects
Kornfeld Eliyahu Peter 3-May-16 4:02am    
Or do some Google and find a .NET wrapper for Twitter API - that you can use from any .NET capable language...

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900