0

Hi I am using Parse and I try to logged in with PHP Code but everytime it writes me {"code":200,"error":"missing username"}

Here is the PHP Code:

$headers = array(
    "Content-Type: application/json",  
    "X-Parse-Application-Id: " . $appId,
    "X-Parse-REST-API-Key: " . $restKey
);          

$username = urlencode('[email protected]');
$password = urlencode('password=test');
$url = "https://api.parse.com/1/login/$username&$password";

$rest = curl_init();  
curl_setopt($rest,CURLOPT_URL,$url);  
curl_setopt($rest,CURLOPT_HTTPGET,1);
curl_setopt($rest,CURLOPT_CUSTOMREQUEST,"GET");  
curl_setopt($rest,CURLOPT_HTTPHEADER,$headers);  
curl_setopt($rest,CURLOPT_SSL_VERIFYPEER, false);  
curl_setopt($rest,CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($rest);  
echo $response;   
curl_close($rest);

What I am missing ?

3
  • 3
    I think a ? has to be before $username. Commented Jul 1, 2014 at 11:04
  • Yes this is the answer but you have to add ? in $url not in $username :) Thank you bro :) Commented Jul 1, 2014 at 11:07
  • @BogdanBogdanov The comment correctly says before $username, not in the variable. Commented Jul 1, 2014 at 11:12

1 Answer 1

1

? before $username in $url :)

$headers = array(
    "Content-Type: application/json",  
    "X-Parse-Application-Id: " . $appId,
    "X-Parse-REST-API-Key: " . $restKey
);          

$username = urlencode('[email protected]');
$password = urlencode('password=test');
$url = "https://api.parse.com/1/login/?$username&$password";

$rest = curl_init();  
curl_setopt($rest,CURLOPT_URL,$url);  
curl_setopt($rest,CURLOPT_HTTPGET,1);
curl_setopt($rest,CURLOPT_CUSTOMREQUEST,"GET");  
curl_setopt($rest,CURLOPT_HTTPHEADER,$headers);  
curl_setopt($rest,CURLOPT_SSL_VERIFYPEER, false);  
curl_setopt($rest,CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($rest);  
echo $response;   
curl_close($rest);
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.