Coldfusion and Twitter JSON


hi there,

 

i running following code found on internet grab load of tweets particular hashtag:

 

    <cfset consumerkey = "my_consumer_key">

    <cfset consumersecret = "my_consumer_secret">

    <cfset bearertoken = tobase64(consumerkey & ":" & consumersecret)>

    <cfset authorization = "basic " & bearertoken>

    

    <cfhttp url="https://api.twitter.com/oauth2/token" method="post" charset="utf-8">

        <cfhttpparam type="header" name="authorization" value="#authorization#">

        <cfhttpparam type="header" name="content-type" value="application/x-www-form-urlencoded;charset=utf-8">

        <cfhttpparam type="body" value="grant_type=client_credentials">

    </cfhttp>

    

    <cfset bearertokenresponse = deserializejson(cfhttp.filecontent)>

    <cfset authorization2 = "bearer " & bearertokenresponse.access_token>

    

    <cfhttp url="https://api.twitter.com/1.1/search/tweets.json" method="get" charset="utf-8">

        <cfhttpparam type="header" name="authorization" value="#authorization2#">

        <cfhttpparam type="url" name="q" value="%23coldfusion">

    </cfhttp>

 

obviously have put in own keys in consumerkey & consumersecret variables.

 

{"statuses":[{"created_at":"tue may 17 16:32:17 +0000 2016","id":732609696109080577,"id_str":"732609696109080577","text":"well done team konstruct! \n\n#konstruct\n#pvd\n#suncity\n#dunhill https:\/\/t.co\/yrupixmq6t","truncated":false,"entities":{"hashtags":[{"text":"konstruct" ,"indices":[28,38]},{"text":"pvd","indices":[39,43]},{"text":"suncity","indices":[44,52]}, {"text":"dunhill","indices":[53,61]}],"symbols":[],"user_mentions":[],"urls":[{"url":"http s:\/\/t.co\/yrupixmq6t","expanded_url":"http:\/\/fb.me\/3kyqtnmle","display_url":"fb.me\/3 kyqtnmle","indices":[62,85]}]},"metadata":{"iso_language_code":"en","result_type":"recent" },"source":"\u003ca href=\"http:\/\/www.facebook.com\/twitter\" rel=\"nofollow\"\u003efacebook\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":238145671,"id_str":"238145671","name":"vincent viljoen","screen_name":"konstructdesign","location":"brackenfell, cape town","description":"i design , build exhibition stands. love when clients win awards stands , brands stand out because of creativity...","url":"http:\/\/t.co\/sogtwplfhi","entities":{"url":{"urls":[{"url":"http: \/\/t.co\/sogtwplfhi","expanded_url":"http:\/\/konstruct.co.za","display_url":"konstruct.c o.za","indices":[0,22]}]},"description":{"urls":[]}},"protected":false,"followers_count":5 89,"friends_count":1973,"listed_count":18,"created_at":"fri jan 14 13:36:08 +0000 2011","favourites_count":0,"utc_offset":7200,"time_zone":"pretoria","geo_enabled":true,"v erified":false,"statuses_count":1863,"lang":"en","contributors_enabled":false,"is_translat or":false,"is_translation_enabled":false,"profile_background_color":"131516","profile_back ground_image_url":"http:\/\/abs.twimg.com\/images\/themes\/theme14\/bg.gif","profile_backg round_image_url_https":"https:\/\/abs.twimg.com\/images\/themes\/theme14\/bg.gif","profile _background_tile":false,"profile_image_url":"http:\/\/pbs.twimg.com\/profile_images\/14657 48472\/vw_1_normal.jpg","profile_image_url_https":"https:\/\/pbs.twimg.com\/profile_images \/1465748472\/vw_1_normal.jpg","profile_banner_url":"https:\/\/pbs.twimg.com\/profile_bann ers\/238145671\/1369226061","profile_link_color":"009999","profile_sidebar_border_color":" ffffff","profile_sidebar_fill_color":"efefef","profile_text_color":"333333","profile_use_b ackground_image":true,"has_extended_profile":false,"default_profile":false,"default_profil e_image":false,"following":null,"follow_request_sent":null,"notifications":null},"geo":nul l,"coordinates":null,"place":null,"contributors":null,"is_quote_status":false,"retweet_cou nt":0,"favorite_count":0,"favorited":false,"retweeted":false,"possibly_sensitive":false,"l ang":"en"}],"search_metadata":{"completed_in":0.015,"max_id":732609696109080577,"max_id_st r":"732609696109080577","query":"%2523konstruct","refresh_url":"?since_id=7326096961090805 77&q=%2523konstruct&include_entities=1","count":15,"since_id":0,"since_id_str":"0"}}

 

i have searched endlessly weeks in way can use display in legible way. instance, suppose wanted output on page, actual tweet(s), handle of posted tweet , date - how!!! driving me mad sure did before can't remember how!

 

many in advance.

 

j

what happens when use deserializejson() on filecontent variable comes second cfhttp call?  not structure can use?

 

also, might want @ (monkeh)tweet twitter api.  if aren't using it, make life easier.

 

nic



More discussions in ColdFusion


adobe

Comments

Popular posts from this blog

Adobe Refresh Managerについて

Sizing images of multiple resolutions for print on a page of one resolution

Illustrator cs6 "Invalid Serial Number"