I'm trying to get the content of a page to use it on my website.
I need the contents from this link.
Then I would like to get the "figureString" from that json page, so I can put it in this link.
I tried using curl but it said that they blocked me because of ddos attempt. I can't use file_get_contents, it says failed to open stream: HTTP request failed! get_remote_data doesn't work either.
<?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)
?>
I got the answer:
$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'];