2012-05-29 48 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