retrieving user time line tweets

Apr 30, 2015 at 12:23 PM
Hi I am trying to retrieve 20 timeline tweets.

I have this so far ->
   http_client api3(U("https://api.twitter.com/1.1/"), m_http_config);
   json::value jsonobj3 = api3.request(methods::GET, U("statuses/home_timeline.json")).get().extract_json().get();
   ucout << jsonobj3;
But it does not print out any tweets.

Any help is appreciated.

Mark
Coordinator
Apr 30, 2015 at 8:07 PM
Hi Mark,

Is the json::value empty? I would recommend examining the http_response object returned from the HTTP request. What is the status code?

Steve
Apr 30, 2015 at 10:28 PM
Hi Steve,

Yeah I am getting the statuses but when i do a search within the json file for text it throws the error where it cant find it.

I just set a breakpoint and looked at them and there is 20 items (0-19).

How would I call the text object?

Mark
Coordinator
May 1, 2015 at 12:38 AM
Hi Mark,

I don't completely follow what you are saying. It sounds like something you are looking for in the json::value is not present. What do you mean by "How would I call the text object"? If there is a JSON object field called 'text' and you want to retrieve its JSON value you could do that with the json::value::at method.

Steve
May 1, 2015 at 12:43 AM
Hi Steve,

I have realized that the problem is once I call the statuses/home_timeline.json Its an array but I am not quite sure how to access the different elements in the array.

Mark

Coordinator
May 1, 2015 at 12:53 AM

Hi Mark,

Use json::value::at or the operator[] or json::value::as_array…

I really recommend looking through the json portions of our reference documentation.

Steve

May 1, 2015 at 1:08 AM
Steve,

After all that I believe its actually objects and not an array.

would this get the second object? ->

json::value &json3_2 = jsonobj3.at(U("1"));
wstring two = json3_2.as_string();

ucout << two;

but then I get an error of "is not an object".

Mark