首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Codeigniter twilio积分

Codeigniter twilio积分
EN

Stack Overflow用户
提问于 2017-07-07 18:07:54
回答 1查看 5.1K关注 0票数 2

我正试图让twilio与我的网站一起发送短信。

以下是我所采取的步骤

首先,我下载了最新的回购程序,并将Twilio文件夹放在/libraries下

然后我又说

代码语言:javascript
复制
$config['composer_autoload'] = '/libraries/Twilio/autoload.php';

到config/config.php

然后在我的控制器里,

我有个功能就是,

代码语言:javascript
复制
$number = 'xx';
$country = '1';

$to = '+'.$country.$number;
require(APPPATH . "/libraries/Twilio/autoload.php");

// Use the REST API Client to make requests to the Twilio REST API
// Your Account SID and Auth Token from twilio.com/console
$sid = "xx"; // Your Account SID from www.twilio.com/console
$token = "xx";
$client = new Twilio\Rest\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
    $to,
    array(
        // A Twilio phone number you purchased at twilio.com/console
        'xxx' => 'ADD Your Free/purchased Number',
        // the body of the text message you'd like to send
        'body' => "Hey Emir! It's Works"
    )
);

所以我的问题是,当我运行视图时,这是我得到的错误,

遇到PHP错误 严重程度:警告 消息: require(/var/www/xxx.com/public_html/application/libraries/Twilio/Twilio/Rest/Client.php):未能打开流:没有这样的文件或目录

因此,出于某种原因,Twilio/autooload.php在路径中添加了另一个/Twilio,我无法理解它。

有什么帮助吗?

EN

回答 1

Stack Overflow用户

发布于 2018-01-10 12:40:36

代码语言:javascript
复制
    // Get the PHP helper library from twilio.com/docs/php/install
require_once 'Full/path/to/vendor/autoload.php'; // Loads the library

use Twilio\Rest\Client;
// Your Account Sid and Auth Token from twilio.com/user/account


$sid = "AC5ef872f6da5a21de157d80997a64bd33";
$token = "your_auth_token";
$client = new Client($sid, $token);
$client->messages->create(
    "+16518675309",
    array(
    'from' => "+14158141829",
    'body' => "Tomorrow's forecast in Financial District, San Francisco is Clear.",
   'mediaUrl' => "https://climacons.herokuapp.com/clear.png",
  )
);
票数 -2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/44977165

复制
相关文章

相似问题

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