du248227 2013-06-23 04:39
浏览 47

如何使用curl rest和php登录解析?

I am trying to do a simple login form to parse but i cant find what is the problem... here is the result i get after this code...

http://wink.hostech.co.il/admin/login.php?username=a%40a.com&password=74b87337454200d4d33f80c4663dc5e5&login=login

    $username = $_POST['username'];
$password = $_POST['password'];

$url = 'https://api.parse.com/1/login.php?username='.$username.'&password='.$password;

$headers = array(
 "Content-Type: application/json" ,
 "X-Parse-Application-Id: {app_id_hidden}" ,
 "X-Parse-REST-API-Key: {key_id_hidden}"
);

$handle = curl_init();
curl_setopt($handle, CURLOPT_URL, $url);    
curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);

$data = curl_exec($handle);
curl_close($handle);

$array = json_decode($data);
echo $array;
print_r($array);
  • 写回答

1条回答 默认 最新

  • duanqie8549 2014-05-21 09:10
    关注
    $url ='https://api.parse.com/1/login';
    $appId = '';  
    $restKey = '';  
    
    $headers = array(
        "Content-Type: application/json",  
        "X-Parse-Application-Id: " . $appId,
        "X-Parse-REST-API-Key: " . $restKey
    );          
    
    $username = "test";
    $password = "test";
    
    $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_ENCODING, 'username=test&password=test');
    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); 
    
    评论

报告相同问题?

悬赏问题

  • ¥15 程序不包含适用于入口点的静态Main方法
  • ¥15 素材场景中光线烘焙后灯光失效
  • ¥15 请教一下各位,为什么我这个没有实现模拟点击
  • ¥15 执行 virtuoso 命令后,界面没有,cadence 启动不起来
  • ¥50 comfyui下连接animatediff节点生成视频质量非常差的原因
  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 ubuntu子系统密码忘记