2015-01-05 41 views
9

這是我第一次使用parse.com PHP SDK,我嘗試執行以下代碼致命錯誤:未捕獲的異常「解析 ParseException的」與消息「SSL證書proble:無法獲取本地頒發者證書」

<?php require '../autoload.php'; 
use Parse\ParseObject; 
use Parse\ParseClient; 
ParseClient::initialize("Zsr...", "BzM..", "D..."); 
$gameScore = new ParseObject("GameScore"); 
$gameScore->set("score", 1337); 
$gameScore->set("playerName", "Sean Plott"); 
$gameScore->set("cheatMode", false); 

try { 
     $gameScore->save(); 
     echo 'New object created with objectId: ' . $gameScore->getObjectId(); 
     } catch (ParseException $ex) { 
      // Execute any logic that should take place if the save fails. 
      // error is a ParseException object with an error code and message. 
      echo 'Failed to create new object, with error message: ' + $ex->getMessage(); 
    } 
?> 

但我得到這個錯誤

Fatal error: Uncaught exception 'Parse\ParseException' with message 'SSL certificate problem: unable to get local issuer certificate' in /opt/lampp/htdocs/parse/src/Parse/ParseClient.php:250 Stack trace: #0 /opt/lampp/htdocs/parse/src/Parse/ParseObject.php(925): Parse\ParseClient::_request('POST', '/1/classes/Game...', NULL, '{"score":1337,"...', false) #1 /opt/lampp/htdocs/parse/src/Parse/ParseObject.php(836): Parse\ParseObject::deepSave(Object(Parse\ParseObject), false) #2 /opt/lampp/htdocs/parse/src/hola.php(11): Parse\ParseObject->save() #3 {main} thrown in /opt/lampp/htdocs/parse/src/Parse/ParseClient.php on line 250 

它的教程代碼的代碼,二沒有改變任何東西的人都知道出了什麼問題?

+0

可能重複的[PHP解析sdk - >你好世界錯誤](http://stackoverflow.com/questions/25516518/php-parse-sdk-hello-world-error) – Maks3w

回答

53

我也遇到同樣的問題。現在我解決了使用其他論壇的答案。

打開ParseClient.php並找到:

curl_init(); 

而那加行後添加:

curl_setopt($rest, CURLOPT_SSL_VERIFYPEER, false); 

它將工作。

+0

不是幾個月前,我是有這麼一段時間。感謝您提供簡單快捷的解決方案! <3 – jjonesdesign

+1

請考慮這個相關的答案,因爲它可能是一個更好的解決方案:http://stackoverflow.com/a/25659839/3562415 – iCaramba

+0

關閉ssl驗證器的好解決方案。如果我找不到這個解決方案,可能是我項目中的一場災難 –

相關問題