ข้อมูลแนวโน้มจาก Twitter Search API ใน JSON
จับไฟล์โดยใช้:
$jsonurl = "http://search.twitter.com/trends.json";
$json = file_get_contents($jsonurl,0,null,null);
$json_output = json_decode($json);
ฉันจะทำงานกับข้อมูลจากวัตถุนี้ได้อย่างไร เป็นอาร์เรย์? จำเป็นต้องดึงข้อมูลจากค่า [name] เท่านั้น
วัตถุ JSON ประกอบด้วย:
stdClass Object
(
[trends] => Array
(
[0] => stdClass Object
(
[name] => Vote
[url] => http://search.twitter.com/search?q=Vote
)
[1] => stdClass Object
(
[name] => Halloween
[url] => http://search.twitter.com/search?q=Halloween
)
[2] => stdClass Object
(
[name] => Starbucks
[url] => http://search.twitter.com/search?q=Starbucks
)
[3] => stdClass Object
(
[name] => #flylady
[url] => http://search.twitter.com/search?q=%23flylady
)
[4] => stdClass Object
(
[name] => #votereport
[url] => http://search.twitter.com/search?q=%23votereport
)
[5] => stdClass Object
(
[name] => Election Day
[url] => http://search.twitter.com/search?q=%22Election+Day%22
)
[6] => stdClass Object
(
[name] => #PubCon
[url] => http://search.twitter.com/search?q=%23PubCon
)
[7] => stdClass Object
(
[name] => #defrag08
[url] => http://search.twitter.com/search?q=%23defrag08
)
[8] => stdClass Object
(
[name] => Melbourne Cup
[url] => http://search.twitter.com/search?q=%22Melbourne+Cup%22
)
[9] => stdClass Object
(
[name] => Cheney
[url] => http://search.twitter.com/search?q=Cheney
)
)
[as_of] => Mon, 03 Nov 2008 21:49:36 +0000
)