0

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.

Tamil Selvan C
  • 19,913
  • 12
  • 49
  • 70
Val
  • 63
  • 9
  • 1
    Do you have access to http://www.[targetdomain].com/api/logged? It is not clear from the question but perhaps it relies on cookies. So here is the problem. – claustrofob May 25 '13 at 16:58
  • Yes, I have access to both servers. I will investigate and I will get back to you. – Val May 29 '13 at 14:55
  • The targetdomain is a symfony platform and it has a session controller for that... The solution was a different module that compares an API key instead of login status. If somebody else will get a new solution I will be more than happy :) – Val Jun 02 '13 at 15:05

1 Answers1

0

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

Val
  • 63
  • 9