@ 2013-09-28T14:26:27Z <?php
/* GET リクエストでのシンプルなAPI */
//URLを指定
$url = "http://www.php.net/";
$res = file_get_contents("http://api.b.st-hatena.com/entry.count?url=".$url);
var_dump($res);
?>
<?php
/* 被ブックマーク合計数取得API */
$request = xmlrpc_encode_request("bookmark.getTotalCount", $url);
$context = stream_context_create(array('http' => array(
'method' => "POST",
'header' => "Content-Type: text/xml",
'content' => $request
)));
$file = file_get_contents("http://b.hatena.ne.jp/xmlrpc", false, $context);
$response = xmlrpc_decode($file);
var_dump($response);
?>
<?php
/* 50件以降も取得する 規制回避 */
function get_HB_favorited_counts(array $urls) {
$ret = array_fill_keys($urls, false);
$base_url = 'http://api.b.st-hatena.com/entry.counts';
foreach (array_chunk($urls, 50) as $set) {
$query = '?' .implode('&', array_map(function ($url) {
return 'url=' . rawurlencode($url);
}, $set));
$res = json_decode(@file_get_contents($base_url . $query), true);
if (is_array($res)) {
foreach ($res as $url => $count) {
$ret[$url] = $count;
}
}
}
return $ret;
}
$urls = array('http://codecanyon.net/',
'http://www.htaccesseditor.com/',
'http://phplab.jp/',
'http://www.php.net/',
'http://nicovideo.jp/',
'http://google.com/',
'http://google.co.jp/',
'http://example.com/',
'http://www.php.gr.jp/',
'http://php-users.jp/',
'http://aws.amazon.com/jp/php/',
'http://www.ioncube.jp/',
'http://amazon.com/',
'http://amazon.co.jp/',
'http://ameblo.jp/',
'http://blog.livedoor.com/',
'http://jugem.jp/',
'http://blog.fc2.com/',
'http://blog.seesaa.jp/contents/about/?via=a8',
'http://d.hatena.ne.jp/',
'http://blog.so-net.ne.jp/',
'http://www.ninja.co.jp/blog/',
'http://plaza.rakuten.co.jp/',
'http://blog.goo.ne.jp/',
'http://www.fruitblog.net/',
'http://www.exblog.jp/',
'http://blog.oricon.co.jp/',
'http://blogs.yahoo.co.jp/',
'http://ja.wordpress.com/',
'http://webryblog.biglobe.ne.jp/',
'http://www.yaplog.jp/',
'http://www.anisen.tv/',
'http://gamecs.jp/',
'http://www.eniblo.com/',
'http://blog.kuruten.jp/',
'http://iralog.net/',
'http://h.hatena.ne.jp/',
'http://www.foodlog.jp/',
'http://www.b-shoku.jp/',
'http://d-nikki.com/',
'http://a-thera.com/',
'http://blog.emachi.co.jp/blog/',
'http://www.areablog.jp/',
'http://www.2chiiki.jp/',
'http://www.zige.jp/',
'http://blog.qlep.com/',
'http://blog.goyah.net/',
'http://blog.saitamania.net/',
'http://fblg.jp/',
'https://arekao.jp/index.php?module=Profile&action=ShowRegistForm',
'http://sl.lcomi.ne.jp/mrs/',
'http://blog.k-plaza.com/',
'http://www.actiblog.com/'
);
foreach (get_HB_favorited_counts($urls) as $key=>$c){
echo $key.'==>'.$c.'<br/>';
}
echo 'Array count==>'.count($urls);
?>
Enable javascript to submit You have javascript disabled. You will not be able to edit any code.
Output for git.master , git.master_jit , rfc.property-hooks Warning: file_get_contents(): php_network_getaddresses: getaddrinfo for api.b.st-hatena.com failed: System error in /in/V93vd on line 7
Warning: file_get_contents(http://api.b.st-hatena.com/entry.count?url=http://www.php.net/): Failed to open stream: php_network_getaddresses: getaddrinfo for api.b.st-hatena.com failed: System error in /in/V93vd on line 7
bool(false)
Fatal error: Uncaught Error: Call to undefined function xmlrpc_encode_request() in /in/V93vd:16
Stack trace:
#0 {main}
thrown in /in/V93vd on line 16
Process exited with code 255 . This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.
Active branches Archived branches Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page
preferences:dark mode live preview
45.61 ms | 401 KiB | 8 Q