2012-05-29 98 views
0

我想在php中編寫一些代碼,以便在某個網站上顯示某個特定網址在推特上的推文次數。來自Twitter API的調用數據

我假設我使用此頁面中的信息; http://api.tweetmeme.com/url_info?url=http://dori.co.nz/

但是我需要添加哪些代碼才能將這些值添加到Wordpress主題的標題中?

非常感謝提前!

+0

http://www.w3schools.com/php/php_xml_simplexml.asp這將有助於你.. – zaw

+0

謝謝,我讀過,但我不能釘它。這是我到目前爲止... – Adam

+0

<? $ url =「http://api.tweetmeme.com/url_info?url=http://dori.co.nz/」; $ xml = file_get_contents($ url); $ xml = simplexml_load_string($ xml); $ shares = $ xml-> result-> story-> url_count; echo $ shares; ?> – Adam

回答

1
<?php 
$url = "http://api.tweetmeme.com/url_info?url=http://dori.co.nz/"; 
$test = file_get_contents($url); 

$xml = simplexml_load_string($test); 
echo $xml->story->url_count; 
?> 

在這裏,我們走了。

+0

非常感謝你! – Adam