php - How can I get a specific value from JSON? -
can me specific item json?
here code
<?php require_once("../twitter/twitteroauth.php"); //path twitteroauth library $twitteruser = "soksovat"; $notweets = 1; $consumerkey = "xxxxx"; $consumersecret = "xxxxxx"; $accesstoken = "xxxxxxx"; $accesstokensecret = "xxxxxxx"; function getconnectionwithaccesstoken($cons_key, $cons_secret, $oauth_token, $oauth_token_secret) { $connection = new twitteroauth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret); return $connection; } $connection = getconnectionwithaccesstoken($consumerkey, $consumersecret, $accesstoken, $accesstokensecret); $tweets = $connection->get("https://api.twitter.com/1.1/statuses/user_timeline.json?screen_name=".$twitteruser."&count=".$notweets); echo json_encode($tweets); ?>
output
[ { "created_at":"thu aug 15 06:20:15 +0000 2013", "id":3.6789347939897e+17, "id_str":"367893479398965248", "text":"\u3050\u308b\u306a\u3073\u98df\u5e02\u5834\u3067\u7523\u5730\u76f4\u9001\u30fb\u7279\u7523\u54c1\u3001\u53b3\u9078\u30bb\u30ec\u30af\u30c8\u3057\u305f\u30b0\u30eb\u30e1\u3092\u304a\u53d6\u308a\u5bc4\u305b\uff01 http:\/\/t.co\/iqrcst2sfc\n[pr]", "source":"tweet button<\/a>", "truncated":false, "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":963434528, "id_str":"963434528", "name":"sok sovat", "screen_name":"soksovat", "location":"cambodia", "description":"it better have piece of bread happy heart have lot of money sadness..!!", "url":"http:\/\/t.co\/2qnb2kpt", "entities":{ "url":{ "urls":[ { "url":"http:\/\/t.co\/2qnb2kpt", "expanded_url":"http:\/\/soksovat.net63.net", "display_url":"soksovat.net63.net", "indices":[ 0, 20 ] } ] }, "description":{ "urls":[ ] } }, "protected":false, "followers_count":10, "friends_count":26, "listed_count":0, "created_at":"thu nov 22 01:47:04 +0000 2012", "favourites_count":0, "utc_offset":null, "time_zone":null, "geo_enabled":false, "verified":false, "statuses_count":174, "lang":"en", "contributors_enabled":false, "is_translator":false, "profile_background_color":"c0deed", "profile_background_image_url":"http:\/\/a0.twimg.com\/images\/themes\/theme1\/bg.png", "profile_background_image_url_https":"https:\/\/si0.twimg.com\/images\/themes\/theme1\/bg.png", "profile_background_tile":false, "profile_image_url":"http:\/\/a0.twimg.com\/profile_images\/2879880469\/060f9351577d0ab019fa5b1036210931_normal.jpeg", "profile_image_url_https":"https:\/\/si0.twimg.com\/profile_images\/2879880469\/060f9351577d0ab019fa5b1036210931_normal.jpeg", "profile_link_color":"0084b4", "profile_sidebar_border_color":"c0deed", "profile_sidebar_fill_color":"ddeef6", "profile_text_color":"333333", "profile_use_background_image":true, "default_profile":true, "default_profile_image":false, "following":null, "follow_request_sent":false, "notifications":null }, "geo":null, "coordinates":null, "place":null, "contributors":null, "retweet_count":0, "favorite_count":0, "entities":{ "hashtags":[ ], "symbols":[ ], "urls":[ { "url":"http:\/\/t.co\/iqrcst2sfc", "expanded_url":"http:\/\/bit.ly\/150qrue", "display_url":"bit.ly\/150qrue", "indices":[ 36, 58 ] } ], "user_mentions":[ ] }, "favorited":false, "retweeted":false, "possibly_sensitive":false, "lang":"ja" } ]
what want
in fact, want
"text":"\u3050\u308b\u306a\u3073\u98df\u5e02\u5834\u3067\u7523\u5730\u76f4\u9001\u30fb\u7279\u7523\u54c1\u3001\u53b3\u9078\u30bb\u30ec\u30af\u30c8\u3057\u305f\u30b0\u30eb\u30e1\u3092\u304a\u53d6\u308a\u5bc4\u305b\uff01 http:\/\/t.co\/iqrcst2sfc\n[pr]"
how can display content inside text?
use
echo json_encode($tweets[0]['text']);
Comments
Post a Comment