douxing8323 2015-09-21 17:18
浏览 29
已采纳

GAE是否支持Plivo?

I've been trying to implement Plivo on my GAE server but I'm getting a 500 error.

I setup Plivo by using Plivo's Github PHP Helper Library. I saved that file as plivo.php on my test server. Then I added plivosend.php with the following code

<?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."}';
    }
}
?>

On my test server (just my website), this sends without any problems. When I put both plivo.php and plivosend.php on GAE, I get the following 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

I have no idea why... The details are extremely limited.

Does anyone have a clue? Does GAE not support Plivo?

  • 写回答

1条回答 默认 最新

  • doukan5332 2015-09-22 05:18
    关注

    Google App Engine restricts many functions (necessary in order to be a massively auto-scaling application platform). One restriction is outbound HTTP requests (from your PHP code to external). Read about it here, HTTP Requests and cURL Support for details and options.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 写一个方法checkPerson,入参实体类Person,出参布尔值
  • ¥15 我想咨询一下路面纹理三维点云数据处理的一些问题,上传的坐标文件里是怎么对无序点进行编号的,以及xy坐标在处理的时候是进行整体模型分片处理的吗
  • ¥15 CSAPPattacklab
  • ¥15 一直显示正在等待HID—ISP
  • ¥15 Python turtle 画图
  • ¥15 关于大棚监测的pcb板设计
  • ¥15 stm32开发clion时遇到的编译问题
  • ¥15 lna设计 源简并电感型共源放大器
  • ¥15 如何用Labview在myRIO上做LCD显示?(语言-开发语言)
  • ¥15 Vue3地图和异步函数使用