0

Breaking out a JSON string

I have an open table at http://hapdaniel.pwp.blueyonder.co.uk/pdaniel/yql/twitter_user_timeline.xml. I'm trying to access tweets using the 1,1 version of the Twitter API.

Having executed y.rest the resp variable contains a JSON string containing the tweets. How do I break this up into separate tweets that can then be processed using Yahoo! Pipes? Thanks.

by
6 Replies
  • hapdaniel,

    something like:

     var params = "id="   id;
                        var resp = y.rest("https://api.twitter.com/1.1/statuses/user_timeline.json?user_id=256053751&trim_user=true").header("Authorization","Bearer "  bearer_token).accept('application/json').contentType('application/json').jsonCompat('new').get().response;
                        y.log(y.xparseJson(resp));              
                        response.object=y.xparseJson(resp)[0];
    

    ? not sure if that is what you were looking for.

    1
  • ok try

     var params = "id="   id;
                        var resp = y.rest("https://api.twitter.com/1.1/statuses/user_timeline.json?user_id=256053751&trim_user=true").header("Authorization","Bearer "  bearer_token).accept('application/json').contentType('application/json').jsonCompat('new').get().response;
    
                                    var parsed = '{"results": '   resp   '}';
                                    response.object=y.xparseJson(parsed);
    
    1
  • Paul, Thanks for that. It worked, but I had to change one line:

    parsed = '{"results": ' plussign resp plussign '}';

    This message board removes plus signs. I find that rather depressing.

    1
  • Hap,

    you are right. that is not good.

    i didn't notice that either. bah.

    Thanks -P

    1
  • for code examples might have to paste and link to gist.github for the time being.

    1
  • Paul, Many many thanks for that. It worked, but I had to change one line:

    parsed = '{"results": ' plussign resp plussign '}';

    This message board removes plus signs. I find that rather depressing. http://supremewallfinishing.com/kitchen-remodeling

    0

Recent Posts

in YQL