Quote:
Originally Posted by lokee81
hm, this didn't work quite right.
The only thing i got saved in my new file was this : [ ] , nothing else.
any other ways of pulling this JSON file ? What have I done wrong here?
|
You use a program to pull a feed.
So in PHP for example it would be something like:
// First get the feed
$my_json_feed = file_get_contents('chaturbate feed url');
// Second decode the json data
$my_json_data = json_decode($my_json_feed);
// Third do something with the data
var_dump($my_json_data);
You can call the program from cron so it launches periodically.
You could use curl in the program to grab the feed too but it is more than a one line operation.
This is the PHP curl code I use to grab urls:
function get_page($urlin,$referin)
{
echo "urlin=" . $urlin . "<br>\n";
echo "referin=" . $referin . "<br>\n";
$returnit="";
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.0.8) Gecko/2009032609 Firefox/3.0.8');
curl_setopt($ch, CURLOPT_TIMEOUT, 60);
curl_setopt($ch, CURLOPT_REFERER, $referin);
curl_setopt($ch, CURLOPT_URL, $urlin);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
$result['EXE'] = curl_exec($ch);
$result['ERR'] = curl_error($ch);
curl_close($ch);
if($result['ERR']>"")
{
$returnit="error - " . $result['ERR'];
}
else
{
$returnit=$result['EXE'];
}
return $returnit;
}
.