简体   繁体   English

PHP版本5.2.3和Twilio,发送短信问题

[英]PHP version 5.2.3 and Twilio, issues with sending SMS

I'm having a bit of trouble sending SMS on my web application using PHP Version 5.2.3 (I have been asked not to update the version). 我在使用PHP版本5.2.3在Web应用程序上发送SMS时遇到了一些麻烦(已要求我不要更新版本)。

I have tried the same code on my local php server (which works fine), which uses 5.5.14. 我已经在本地PHP服务器(工作正常)上尝试了相同的代码,该服务器使用5.5.14。 That code is: 该代码是:

<?php
    require 'twilio-php-master/Services/Twilio.php';
    $account_sid = 'sadasdasd123'; 
    $auth_token = 'sdfsdfdsfds678'; 
    $client = new Services_Twilio($account_sid, $auth_token); 
    try {
        $message = $client->account->messages->create(array(
            "From" => "1234567890",
            "To" => "9876543211",
            "Body" => "Test message!"
        ));
    } catch (Services_Twilio_RestException $e) {
        echo $e->getMessage();
    }

    echo "Sent message {$message->sid}";
?>

According to the Twilio PHP documentation , 5.2.3 is the minimum version you can use. 根据Twilio PHP文档 ,您可以使用最低版本5.2.3。

Any ideas on this issue are greatly appreciated. 对此问题的任何想法将不胜感激。 As stated, I cannot update the PHP 5.2.3 version. 如前所述,我无法更新PHP 5.2.3版本。

They have updated their documentation and recently i faced this issue so after research i was able to sending sms and writing the steps you should follow and it would work. 他们更新了文档,最近我遇到了这个问题,因此经过研究,我能够发送短信并编写您应该遵循的步骤,这样才可以正常工作。

Download    [https://github.com/twilio/twilio-php/archive/master.zip][1]
Refernce    [https://www.twilio.com/docs/api/rest/sending-messages][1]

require_once("/path/Twilio.php");

$client     =       new Services_Twilio(ACCOUNTSID, AUTHTOKEN);
$sms_from   =       "+1XXXXXXXXXX";
$sms_to     =       "+1XXXXXXXXXX";
$sms_body   =       "test Message";
$message    =       $client->account->messages->sendMessage($sms_from, $sms_to, $sms_body);

echo "<pre>"; print_r($message); echo "</pre>";

It should work on 5.2.3 它应该在5.2.3上工作

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM