Php 从habbo的json页面获取内容
我正在尝试获取一个页面的内容,以便在我的网站上使用它 我需要链接的内容 然后我想从json页面中获取“figureString”, 所以我可以把它放在链接中 我尝试使用curl,但它说他们阻止我是因为ddos尝试。 我不能使用file\u get\u内容,它说无法打开流:HTTP请求失败强> 获取远程数据也不起作用Php 从habbo的json页面获取内容,php,json,http,curl,file-get-contents,Php,Json,Http,Curl,File Get Contents,我正在尝试获取一个页面的内容,以便在我的网站上使用它 我需要链接的内容 然后我想从json页面中获取“figureString”, 所以我可以把它放在链接中 我尝试使用curl,但它说他们阻止我是因为ddos尝试。 我不能使用file\u get\u内容,它说无法打开流:HTTP请求失败 获取远程数据也不起作用 <?php echo "WELCOME ".$r->habboname; $curl_handle=curl_init(); curl_setopt($curl_handl
<?php
echo "WELCOME ".$r->habboname;
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL, 'https://www.habbo.nl/api/public/users?name='.$r->habboname);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'myproject');
$query = curl_exec($curl_handle);
curl_close($curl_handle);
echo 'Query: '.$query;
$json = json_decode($query, true);
echo '<pre>' . print_r($json, true) . '</pre>';
echo get_remote_data('https://www.habbo.nl/api/public/users?name='.$r->habboname, true );
file_get_contents(filename)
?>
我得到了答案:
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'http://www.habbo.nl/api/public/users?name='.$r->habboname);
curl_setopt($ch, CURLOPT_USERAGENT, 'github.com/gerbenjacobs/habbo-api v2.2.0');
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
// urls at /extradata/ require javascript/cookie validation, trick them.
$data = curl_exec($ch);
$info = curl_getinfo($ch);
curl_close($ch);
$json=json_decode($data, true);
echo $json['figureString'];