topic description
I want to get information through the json of the website. I don"t know why I can"t get it. It"s normal that the json URL has been tested. Do you guys help me to study the code to see what"s wrong?
sources of topics and their own ideas
it seems normal to get data, and I feel that the problem appears in $timeline=json_decode ($timeline,true);
here, alas
related codes
<?php
function get_file_content($url,$fgc=false){
$file_contents="";
if($fgc&&function_exists("file_get_contents")){
$file_contents=@file_get_contents($url);
}
if(empty($file_contents)){
$ch=curl_init();
$timeout=5;
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,1);
curl_setopt($ch,CURLOPT_CONNECTTIMEOUT,$timeout);
$file_contents=curl_exec($ch);
curl_close($ch);
}
return $file_contents;
}
$timeline=get_file_content("json");
$timeline=json_decode($timeline,true);
if($timeline){
$title=$timeline["posts"][0]["title"];
echo $title;
}else{
echo(0);
}
?>