根据leancloud的官方文档,用php里的curl来访问RESTAPI的时候,一直无法完成相应的功能,比如官方文档例子里创建一个GameScore的对象,php代码如下,设置好了访问url和appid等相关参数了,执行的时候最后只返回一个0,别的什么都没有,leancloud的控制台里看不到创建的对象,控制台里原来手动创建国GameScore 这个class
php
$headers = array( 'Content-Type: application/json', 'X-AVOSCloud-Application-Id: '.$appID, 'X-AVOSCloud-Application-Key: '.$appKey ); $dataJson = json_encode( array( 'score' => 2015, 'playerName' => 'Tom Raidol', 'cheatMode'=> true ) ); $curlConn = curl_init(); curl_setopt($curlConn, CURLOPT_TIMEOUT, 30); curl_setopt($curlConn, CURLOPT_USERAGENT, 'AVOSCloud.com-php-library/2.0'); curl_setopt($curlConn, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlConn, CURLINFO_HEADER_OUT, true); curl_setopt($curlConn, CURLOPT_HTTPHEADER, $headers); curl_setopt($curlConn, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curlConn, CURLOPT_POSTFIELDS, $dataJson); curl_setopt($curlConn, CURLOPT_URL, $leancloudAPI); $response = curl_exec($curlConn); print_r($response); $responseCode = curl_getinfo($curlConn, CURLINFO_HTTP_CODE); echo $responseCode;
根据leancloud的官方文档,用php里的curl来访问RESTAPI的时候,一直无法完成相应的功能,比如官方文档例子里创建一个GameScore的对象,php代码如下,设置好了访问url和appid等相关参数了,执行的时候最后只返回一个0,别的什么都没有,leancloud的控制台里看不到创建的对象,控制台里原来手动创建国GameScore 这个class
php
$headers = array( 'Content-Type: application/json', 'X-AVOSCloud-Application-Id: '.$appID, 'X-AVOSCloud-Application-Key: '.$appKey ); $dataJson = json_encode( array( 'score' => 2015, 'playerName' => 'Tom Raidol', 'cheatMode'=> true ) ); $curlConn = curl_init(); curl_setopt($curlConn, CURLOPT_TIMEOUT, 30); curl_setopt($curlConn, CURLOPT_USERAGENT, 'AVOSCloud.com-php-library/2.0'); curl_setopt($curlConn, CURLOPT_RETURNTRANSFER, true); curl_setopt($curlConn, CURLINFO_HEADER_OUT, true); curl_setopt($curlConn, CURLOPT_HTTPHEADER, $headers); curl_setopt($curlConn, CURLOPT_CUSTOMREQUEST, "POST"); curl_setopt($curlConn, CURLOPT_POSTFIELDS, $dataJson); curl_setopt($curlConn, CURLOPT_URL, $leancloudAPI); $response = curl_exec($curlConn); print_r($response); $responseCode = curl_getinfo($curlConn, CURLINFO_HTTP_CODE); echo $responseCode;
坑爹的SSL
请问怎么解决的
LeanCloud 已经发布了官方的 php-sdk :https://github.com/leancloud/php-sdk ,对 REST API 有很好的封装,建议参考。
已抢23721个
抢已抢118201个
抢已抢139483个
抢已抢6321个
抢已抢36348个
抢已抢66928个
抢