从 habbo 的 json 页面获取内容

Get contents from a json page from habbo

我正在尝试获取页面内容以在我的网站上使用它。

我需要 this link 的内容。

然后我想从 json 页面获取 "figureString", 所以我可以把它放在 this link.

我尝试使用 curl,但它说他们因为 ddos​​ 尝试而阻止了我。 我无法使用 file_get_contents,它显示 无法打开流:HTTP 请求失败! get_remote_data 也不行。

<?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'];