According to Leancloud's official documentation, when using curl in PHP to access Restapi, it has been unable to complete the corresponding functions, such as the official document example to create a Gamescore object, PHP code as follows, set the access URL and AppID and other related parameters, When the execution of the last only return a 0, nothing else, Leancloud console can not see the creation of the object, the console originally created manually gamescore this 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 ' and ' 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;
Reply content:
According to Leancloud's official documentation, when using curl in PHP to access Restapi, it has been unable to complete the corresponding functions, such as the official document example to create a Gamescore object, PHP code as follows, set the access URL and AppID and other related parameters, When the execution of the last only return a 0, nothing else, Leancloud console can not see the creation of the object, the console originally created manually gamescore this 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 ' and ' 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;
Pit Daddy's SSL
How can i solve the problem?
Leancloud has released the official PHP-SDK:HTTPS://GITHUB.COM/LEANCLOUD/PHP-SDK, which has a good package for REST API, which is recommended for reference.