문제

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.

도움이 되었습니까?

해결책

The script was written to ask a more complex query including api code so it's a back / forth response.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top