如何使用Twilio从Wordpress发送短信?

时间:2013-01-28 04:57:46

标签: php wordpress twilio

我正在尝试在Wordpress应用程序中使用Twilio并且它不起作用,但我的相同代码在不同的站点/服务器中工作。

我添加了twilio-php文件夹和一些PHP代码,以便在wordpress root中调用它。我还添加了代码,将其包含在现有的Wordpress PHP代码中,我无法弄清楚问题出在哪里。你能帮忙吗?

<?php              

                require "twilio-php/Services/Twilio.php";
               /* Send an SMS using Twilio. You can run this file 3 different ways:
                *
                * - Save it as sendnotifications.php and at the command line, run 
                *        php sendnotifications.php
                *
                * - Upload it to a web host and load mywebhost.com/sendnotifications.php 
                *   in a web browser.
                * - Download a local server like WAMP, MAMP or XAMPP. Point the web root 
                *   directory to the folder containing this file, and load 
                *   localhost:8888/sendnotifications.php in a web browser.
                */
                // Include the PHP Twilio library. You need to download the library from 
                // twilio.com/docs/libraries, and move it into the folder containing this 
                // file.


                // Set our AccountSid and AuthToken from twilio.com/user/account
                $AccountSid = "********************";
                $AuthToken = "*********************";

               // Instantiate a new Twilio Rest Client
               $client = new Services_Twilio($AccountSid, $AuthToken);

               /* Your Twilio Number or Outgoing Caller ID */
               $from = '**********';

               // make an associative array of server admins. Feel free to change/add your 
               // own phone number and name here.
               $people = array(
                "*********" => "******",
                "**********" => "*********",


               );

              // Iterate over all admins in the $people array. $to is the phone number, 
              // $name is the user's name
              foreach ($people as $to => $name) {
                 // Send a new outgoing SMS */
                 $body = "Hello this is a test message";
                 $client->account->sms_messages->create($from, $to, $body);
                 echo "Sent message to $name";
              }

?>

1 个答案:

答案 0 :(得分:0)

我检查服务器日志并注意到服务器中没有安装curel然后我安装并重新启动服务器,现在它工作正常,谢谢你的大力支持...... Kevin Burke thanx:D