由于https,Twilio入站请求网址失败

时间:2016-09-17 04:22:16

标签: laravel twilio

我在我的laravel应用程序中使用twilio服务用于sms功能。我也使用入站请求URL的sms停止功能。还启用了自动消息服务。所有工作正常与http url但不能使用https.I知道twilio使用严格的SSL验证来正常工作。为此,我给twilio支持电子邮件,他们回复说你的SSL评级是" F"。正确地工作twilio需要" A"在这次讨论之后,现在我的SSL评级是A,但仍然没有woking。在此twilio回复后: -

"如果它的200 ok,Twilio服务器正在期待一个Twiml。如果您愿意,可以返回HTTP 204 No Content,没有响应正文。或者,如果它更容易,您可以将响应设置为"内容类型:text / plain"并返回一个0长度的响应体。"

我设置了标题类型" text / plain"和content-length = 0,但我认为这不起作用。

当入站请求调用然后入站请求url自动调用并且函数在下面执行: -

public function stopSms() {

    $response = Response::make('', 200, ['Content-Length' => 0]);
    $response->header('Content-Type', 'text/plain');

    $sms_response = Input::all();
    $body_name = trim($sms_response['Body'], '"');
    $phone_number = trim($sms_response['From'], '"');
    $user = User::where('phone_number', '=', $phone_number);
    if ($user->count()) {
        if ($body_name == "OPT-OUT" || $body_name == "STOP" || $body_name == "END" || $body_name == "QUIT" || $body_name == "CANCEL" || $body_name == "UNSUBSCRIBE") {
            // To get user info
            $user = $user->first();
            $user->sms_consent = 0;
            if ($user->save()) {
                Sms::send(array('to' => "$phone_number", 'text' => "You will no longer receive sms messages from Simplistic Sentiments. To start messages, reply OPT-IN or reply with HELP for more options"));
                return $response;
            }
        } else if ($body_name == "OPT-IN" || $body_name == "START" || $body_name == "YES") {
            // To get user info
            $user = $user->first();
            $user->sms_consent = 1;
            if ($user->save()) {
                Sms::send(array('to' => "$phone_number", 'text' => "You will now receive sms messages from Simplistic Sentiments. To stop messages, reply OPT-OUT or reply with HELP for more options"));
                return $response;
            }
        } else if ($body_name == "HELP" || $body_name == "INFO") {
            // To get user info
            $txt = "To stop messages reply with these keyword: \n";
            $txt .= "OPT-OUT,STOP,END,QUIT and UNSUBSCRIBE\n";
            $txt .= "To start messages reply with these keyword: \n";
            $txt .= "OPT-IN,START and YES";
            try {
                Sms::send(array('to' => "$phone_number", 'text' => $txt));
            } catch (Exception $e) {
                return $e->getMessage();
            }
            return $response;
        } else {
            Sms::send(array('to' => "$phone_number", 'text' => "You entered wrong keyword. Please enter correct keyword. To stop, reply OPT-OUT and to Start, reply OPT-IN"));
            return $response;
        }
    }else{
        return $response;
    }
}

请帮我解决这个问题。谢谢

0 个答案:

没有答案