The script was written to ask a more complex query including api code so it's a back / forth response.
json_decode() returns different answer
Question
I need to check if the user is logged in through json api. The json api URL must be: http://www.[targetdomain].com/api/logged?s_email=MY_EMAIL and if the specified email is logged in the response is
{ 'user': 'true' }
If the user is not logged in, the response is
{ 'user': 'false' }
My PHP code to the destination is:
<?php
$s_email = 'myemail@email.com';
$ez_get="http://www.[targetdomain].com/api/logged?s_email=".$s_email."";
$raw = file_get_contents($ez_get);
$objs = str_replace("'", "\"", $raw);
$obj = json_decode($objs);
echo $obj->{"user"};
?>
<iframe frameborder="0" allowtransparency="true" src="<?php echo $ez_get; ?>" scrolling="no"></iframe>
The user is logged in. If I check the api in my browser typing the full URL the api response is true.
From php part I get the echo false. In iFrame the result is true.
What am I doing wrong? I was digging through stackoverflow and it seems it is a matter of header but CURL is not activated on my server. Your response is highly appreciated.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow