我的Twilio PHP,我的HTML表单在本地运行得很好,但是当我把文件放到我的Wordpress主题文件夹中,并试图通过在header.php中的标签前添加下面这行代码来包含PHP文件:
<?php include 'sendnotifications.php';?>
我的页面上有这样的错误:
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
编辑:
它起作用了,我没有把文件放在好的文件夹里。现在我有了另一个问题,它只适用于预定义的电话号码:
$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!'
但是,当我尝试从页面上的表单中获取自定义电话号码时:
$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!'
我有这个错误
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
我有点迷路了
发布于 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
https://stackoverflow.com/questions/50563229
复制相似问题