2015-09-21 45 views
0

我一直在嘗試在我的GAE服務器上實現Plivo,但我得到了500 errorGAE是否支持Plivo?

我使用Plivo's Github PHP Helper Library設置了Plivo。我在測試服務器上將該文件保存爲plivo.php。然後我說plivosend.php用下面的代碼

<?php 
if($_POST) { 
    require_once 'plivo.php'; 
    $auth_id = "auth_id"; 
    $auth_token = "auth_token"; 

    $p = new RestAPI($auth_id, $auth_token); 

    // make sure all 3 params are valid 
    if(!empty($_POST['send_to_name']) && !empty($_POST['send_to_number']) && !empty($_POST['sender_name'])) { 

     $message = 'this message doesn't matter'; 
     $plivo_url = 'https://glacial-harbor-8656.herokuapp.com/report'; 

     // Send message 
     $params = array(
       'src' => '15555555555',    // Sender's phone number with country code 
       'dst' => $_POST['send_to_number'], // Receiver's phone number with country code 
       'text' => $message,     // Your SMS text message 
       'url' => $plivo_url,    // The URL to which with the status of the message is sent 
       'method' => 'POST'     // The method used to call the url 
      ); 

     // Send message 
     $response = $p->send_message($params); 

     // Print the response 
     $message_uuid = $response['response']['message_uuid'][0]; 

     if(!empty($message_uuid)) { 
      echo '{"success":1,"message_uuid":' . $message_uuid . '"}'; 
     } 
     else { 
      // todo log this? 
      echo '{"success":0,"error_message":"Message failed to send."}'; 
     } 
    } 
    else { 
     echo '{"success":0,"error_message":"Message failed to send. Incorrect params."}'; 
    } 
} 
?> 

在我的測試服務器上(只是我的網站),這將沒有任何問題。當我把兩個plivo.phpplivosend.php在GAE上,我得到以下500 error

207.58.203.50 - - [21/Sep/2015:09:58:00 -0700] "POST /plivosend.php HTTP/1.1" 500 25 - "appname/1.0.2 (iPhone; iOS 9.0; Scale/2.00)" "appname-xxx.appspot.com" ms=4 cpu_ms=3 cpm_usd=0.000003 instance=00c61b117cd04d3645448a84e24daba9991882e1 app_engine_release=1.9.26 

我不知道爲什麼...詳細是極其有限的。

有沒有人有線索? GAE不支持Plivo嗎?

+0

什麼是「非常有限的細節」?另請參閱[有關應用引擎捲曲的詳細信息](https://cloud.google.com/appengine/docs/php/#PHP_cURL_support) –

回答

1

Google App Engine限制了許多功能(爲了成爲一個大規模自動擴展應用平臺所必需的)。一個限制是出站HTTP請求(從您的PHP代碼到外部)。請閱讀此處,HTTP Requests and cURL Support瞭解詳情和選項。