首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >在Wordpress中集成Twilio PHP

在Wordpress中集成Twilio PHP
EN

Stack Overflow用户
提问于 2018-05-28 17:33:34
回答 1查看 799关注 0票数 0

我的Twilio PHP,我的HTML表单在本地运行得很好,但是当我把文件放到我的Wordpress主题文件夹中,并试图通过在header.php中的标签前添加下面这行代码来包含PHP文件:

代码语言:javascript
复制
<?php include 'sendnotifications.php';?>

我的页面上有这样的错误:

代码语言:javascript
复制
Warning: include(): Failed opening 'sendnotifications.php' for
 inclusion (include_path='.:/usr/lib/php7.1') in 
/htdocs/clickandbuilds/MyWebsite/wp-content/themes/Divi/header.php on line 3

编辑:

它起作用了,我没有把文件放在好的文件夹里。现在我有了另一个问题,它只适用于预定义的电话号码:

代码语言:javascript
复制
$sid = 'MySID';
$token = 'MyToken';
$client = new Client($sid, $token);

    // Use the client to do fun stuff like send text messages!
    $client->messages->create(
        // the number you'd like to send the message to
       'MyPersonal number',  
        array(
            // A Twilio phone number you purchased at twilio.com/console
            'from' => 'MyTwilioNumber',
            // the body of the text message you'd like to send
            'body' => 'Hey Jenny! Good luck on the bar exam!'

但是,当我尝试从页面上的表单中获取自定义电话号码时:

代码语言:javascript
复制
$sid = 'MySID';
$token = 'MyToken';
$client = new Client($sid, $token);
$phone=$_POST["phone"];

            // Use the client to do fun stuff like send text messages!
            $client->messages->create(
                // the number you'd like to send the message to
               $phone,  
                array(
                    // A Twilio phone number you purchased at twilio.com/console
                    'from' => 'MyTwilioNumber',
                    // the body of the text message you'd like to send
                    'body' => 'Hey Jenny! Good luck on the bar exam!'

我有这个错误

代码语言:javascript
复制
Fatal error: Uncaught Twilio\Exceptions\RestException: [HTTP 400] Unable to create record: A 'To' phone number is required. in /homepages/10/d659162273/htdocs/clickandbuilds/MyWebsite/wp-content/themes/Divi/vendor/twilio/sdk/Twilio/Version.php:85 Stack trace: #0 /homepages/10/d659162273/htdocs/clickandbuilds/MyWebsite/wp-content/themes/Divi/vendor/twilio/sdk/Twilio/Version.php(219): Twilio\Version->exception(Object(Twilio\Http\Response), 'Unable to creat...') #1 /homepages/10/d659162273/htdocs/clickandbuilds/MyWebsite/wp-content/themes/Divi/vendor/twilio/sdk/Twilio/Rest/Api/V2010/Account/MessageList.php(69): Twilio\Version->create('POST', '/Accounts/AC8ec...', Array, Array) #2 /homepages/10/d659162273/htdocs/clickandbuilds/MyWebsite/wp-content/themes/Divi/sendnotifications.php(20): Twilio\Rest\Api\V2010\Account\MessageList->create(NULL, Object(Twilio\Values)) #3 /homepages/10/d659162273/htdocs/clickandbuilds/MyWebsite/wp-content/themes/Divi/header.php(3): include('/homepag in /homepages/10/d659162273/htdocs/clickandbuilds/MyWebsite/wp-content/themes/Divi/vendor/twilio/sdk/Twilio/Version.php on line 85

我有点迷路了

EN

回答 1

Stack Overflow用户

发布于 2018-05-28 17:40:12

你应该安装wordpress的twilio插件才能让它与wordpress一起工作。

这是download的插件链接。在那之后,你将不得不写你的代码。

在下面的链接上关注wordpress的twilio的官方教程:

https://www.twilio.com/blog/2017/08/send-sms-wordpress-php-plugin.html

票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50563229

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档