首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >致命错误:找不到类“Services_Twilio”

致命错误:找不到类“Services_Twilio”
EN

Stack Overflow用户
提问于 2013-12-05 18:34:37
回答 1查看 3.5K关注 0票数 1

当使用Twilio的测试帐户提交表单时,我试图发送一条短信,但是我收到了以下错误:“致命错误:类'Services_Twilio‘未找到’

我的代码如下:

代码语言:javascript
复制
} else{
        //PHP native
        mail( $to_guest, $subject, $html_text, $header_guest);
        // Outlet Admin notification email
        mail( $to_admin, $subject, $notification_text, $header_admin);

/* 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.
     */

    // Step 1: Download the Twilio-PHP library from twilio.com/docs/libraries, 
    // and move it into the folder containing this file.
    require ('http://xzenweb.co.uk/reservation/web/twilio-php/Services/Twilio.php');

    // Step 2: set our AccountSid and AuthToken from www.twilio.com/user/account
    $AccountSid = "";
    $AuthToken = "";

    // Step 3: instantiate a new Twilio Rest Client
    $client = new Services_Twilio($AccountSid, $AuthToken);

    // Step 4: make an array of people we know, to send them a message. 
    // Feel free to change/add your own phone number and name here.
    $people = array(
        "+44463463241" => "Andrew Charlton",
    );

    // Step 5: Loop over all our friends. $number is a phone number above, and 
    // $name is the name next to it
    foreach ($people as $number => $name) {

        $sms = $client->account->messages->sendMessage(

        // Step 6: Change the 'From' number below to be a valid Twilio number 
        // that you've purchased, or the (deprecated) Sandbox number
            "YYY-YYY-YYYY", 

            // the number we are sending to - Any phone number
            +44463463241,

            // the sms body
            "Hey $name, Monkey Party at 6PM. Bring Bananas!"
        );

        // Display a confirmation message on the screen
        echo "Sent message to $name";
    }


    }

我把我的帐户ID和authtoken放在了上面。

有什么问题吗?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2013-12-05 19:39:41

所以你使用require。根据文档包括中的一个,require打开一个文件并对其后面的代码进行回溯。它在使用它的方式上所做的是:从http://xzenweb.co.uk/reservation/web/twilio-php/Services/Twilio.php获取文件(whitch根本不返回任何内容)和evals id (等于零)。这就是你的要求失败的原因。

如果您想要求/包括这段coe,您应该从http://xzenweb.co.uk/reservation/web/twilio-php/Services/Twilio.php下载源代码并将其放在代码环境中。

如果我对Twilio的理解是正确的,那么它们将被用作rest rest服务。如果您想下载其余的客户端代码(如这里所描述的http://www.twilio.com/docs/api/rest/sending-messages ),然后所有这些都提交给您;-)

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

https://stackoverflow.com/questions/20407909

复制
相关文章

相似问题

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