<h4>妈的智障,妈的智障,妈的智障。远程不了公司电脑了,只好本机重新搭建一下环境了</h4>
系统环境:
win7
命令行操作:
composer 管理工具:
基于Yii2框架:
git 命令:
php 环境:xampp 或者 phpstudy:
(步骤1) 安装composer 管理工具:
记得顺便安装插件 composer global require "fxp/composer-asset-plugin:*" 应该是文件传输插件
(步骤2)安装git管理工具
(步骤3)创建新的yii2框架。
composer create-project --prefer-dist yiisoft/yii2-app-basic Twilioproject
composer update
最后安装插件
注意:过程中需要github的token:点进去寻找tokens
(步骤4) 添加插件到yii2框架中
进入yii2项目目录
composer require --prefer-dist filipajdacic/yii2-twilio "*"
出现问题:
Your requirements could not be resolved to an installable set of packages.
Problem 1
- The requested package filipajdacic/yii2-twilio * is satisfiable by filipaj
dacic/yii2-twilio[dev-master] but these conflict with your requirements or minim
um-stability.
方案:
打开项目的composer.phar更改 为 "minimum-stability": "dev",
========================================================================
(win环境下:正式开始twilio在php开发的使用)
1.进入:config/web.php
'components' => array(
...
'Yii2Twilio' => array( 'class' => 'filipajdacic\yiitwilio\YiiTwilio',
'account_sid' => 'YOUR_TWILIO_ACCOUNT_SID_HERE',
'auth_key' => 'YOUR_TWILIO_AUTH_KEY_HERE', ),
...
);
2.在controller/sitecontroller 添加方法
该方法用于测试。twilio是否能在yii框架上运行
/**
* Displays phonesystem page.
*
* @展示打电话系统页面
*/
public function actionPhonesystem()
{
// return $this->render('phonesystem');
$twilioService = Yii::$app->Yii2Twilio->initTwilio();
try {
$message = $twilioService->account->messages->create(array(
"From" => "+12345678901", // From a valid Twilio number
"To" => "+12345678901", // Text this number
"Body" => "Hello from my Yii2 Application!",
));
} catch (\Services_Twilio_RestException $e) {
echo $e->getMessage();
}
}
出现问题:
1 找不到service class
PHP Fatal Error – [yii\base\ErrorException](http://www.yiiframework.com/doc-2.0/yii-base-errorexception.html)
Class 'Services_Twilio' not found
解决办法:
在vendor-> composer-> autoload_files.php 中 增加:
'bccfaf6207f67190a92f35585e9a78b2' => $vendorDir . '/twilio/sdk/Services/Twilio.php',
并且替换掉 /twilio/sdk/Service文件。
文件在360云盘:488087887@qq.com
https://yunpan.cn/cMbcIphrUH97I (提取码:1f21)
2.SSL 证书安全
Services_Twilio_HttpException
The OpenSSL extension is required but not currently enabled. For more information, see
http://php.net/manual/en/book.openssl.php
解决办法:
php文件的php.ini 去掉;
extension=php_openssl.dll
然后:http://stackoverflow.com/questions/29153819/twilio-php-ssl-certificate-self-signed-certificate-in-certificate-chain
网友评论