有人可以在這方面的信息,目前還不清楚,如果這個api甚至能夠通過網址搜索,搜索谷G,沒有太多的成功。使用Services_Digg2與PHP的URL獲取Digg的計數
關於新Services_Digg2梨包中的一些信息:
http://digg.com/api/docs/servicesdigg2
有人可以在這方面的信息,目前還不清楚,如果這個api甚至能夠通過網址搜索,搜索谷G,沒有太多的成功。使用Services_Digg2與PHP的URL獲取Digg的計數
關於新Services_Digg2梨包中的一些信息:
http://digg.com/api/docs/servicesdigg2
Services_Digg2只是一個客戶端庫在PHP轉發到API的所有調用和API不支持通過網址搜索。你需要傳遞的是網址的md5哈希值,而不是實際的網址。 PHP有一個md5函數,您可以使用它來獲取url的md5哈希值。
然後,API調用將用於story.getAll
,並且您將先前計算的md5散列作爲參數link_hash
傳遞。
http://services.digg.com/1.0/endpoint?method=story.getAll&link_hash=a23658a0828e2fb388b7c83f61e235e6
上面這哈希是針對URL http://www.nytimes.com/2010/01/05/health/05docs.html和來自API的響應是:
<stories timestamp="1262740374" total="1" offset="0" count="1">
<story link="http://www.nytimes.com/2010/01/05/health/05docs.html" submit_date="1262729293" diggs="70" id="18288654" comments="6" href="http://digg.com/health/For_F_D_R_Sleuths_New_Focus_on_an_Odd_Spot" promote_date="1262739603" status="popular" media="news">
<description>Look closely at Roosevelt’s portraits over his 12-year presidency. In his first two terms, there is a dark spot over his left eyebrow. It seems to grow and then mysteriously vanishes sometime around 1940, leaving a small scar. </description>
<title>For F.D.R. Sleuths, New Focus on an Odd Spot</title>
<user name="leaprinces" registered="1227624484" profileviews="23186" fullname="Princess Leia" icon="http://digg.com/users/leaprinces/l.png" />
<topic name="Health" short_name="health" />
<container name="Lifestyle" short_name="lifestyle" />
<thumbnail originalwidth="190" originalheight="126" contentType="image/jpeg" src="http://digg.com/health/For_F_D_R_Sleuths_New_Focus_on_an_Odd_Spot/t.jpg" width="80" height="80" />
<shorturl short_url="http://digg.com/d31EjiI" view_count="192" />
</story>
</stories>
在此響應故事元素有一個名爲diggs
的屬性,是你所需要的。
要通過PHP庫得到這個,代碼應該是這個樣子:
$url = "...";
$api = new Services_Digg2;
$stories = $api->story->getAll(array('link_hash' => md5($url)))->stories;
foreach($stories as $story) {
// I am not sure how to access the diggs attribute
// Maybe this works. If not, just
// var_dump the $story object and
// see how to access the digg count information.
echo $story['diggs'];
}
非常感謝,這是我需要的 – pentarim 2010-01-06 12:16:03
這不再工作。 – 2014-08-23 03:30:30
你嘗試爲B搜索? – Anurag 2010-01-06 00:59:17