0

Why my this script does not echo user like through Facebook API by using user access token..... Thanks in advance

$chut=json_decode(file_get_contents('https://graph.facebook.com/me?access_token='.$token),true);
$uid = $chut['id'];

$limit = 80;
$br = "<br>";
$feed=json_decode(file_get_contents('https://graph.fb.me/'.$uid.'/feed?access_token='.$token.'&limit=1'),true);
{

$idstt = $feed['data'][0]['id'];
$stt = explode("_", $idstt);
$idstt= $stt[1];
$sllike = $feed['data'][0]['likes']['count'];
echo $uid;
echo $br;
echo $idstt;
echo $br;
echo $sllike;
}
if($sllike < $limit)
{
$try = new kubon;
$try->token = $token;
$try->id    = $idstt;
$try->run();
}
  • Check what file_get_contents returns, _before_ trying to decode it as JSON. – CBroe Jul 25 '17 at 13:24
  • I checked...... it echo user id but not user like @CBroe – Nalin Nishant Jul 25 '17 at 13:25
  • Check what file_get_contents returned, not what any other variables may or may not contain after you tried to decode a response that probably was not JSON. – CBroe Jul 25 '17 at 13:26
  • It was in json ...... Well I am learner so can you help me through code.......humble req – Nalin Nishant Jul 25 '17 at 13:27
  • Don’t do multiple operations in one line. Make the request to the API using file_get_contents first, assign the return value to a variable. Then verify if that variable contains what you expected, or something else. Only after that, try to decode it. – CBroe Jul 25 '17 at 13:29
  • Can you give me example.. :-) – Nalin Nishant Jul 25 '17 at 13:30
  • If there is no actual error, and you do get JSON back from the API - then it likely does not contain the fields you are looking for, because you neglected to _ask_ for them, as you have to do since API v2.4. In that case, check https://stackoverflow.com/q/32584850/1427878 – CBroe Jul 25 '17 at 13:30
  • FYI everyone, same question under different account: https://stackoverflow.com/questions/45308553/not-getting-user-status-like-facebook – CBroe Jul 26 '17 at 07:41

0 Answers0