simperfit/twilio-bundle

一个简单的用于Twilio官方SDK的Symfony 2, 3扩展包。

安装次数: 418,198

依赖关系: 0

建议者: 0

安全性: 0

星标: 1

关注者: 1

分支: 45

类型:symfony-bundle

1.2.0 2022-11-22 09:17 UTC

This package is auto-updated.

Last update: 2024-09-22 12:58:07 UTC


README

Symfony Twilio Bundle - 由 Fridolin Koch 创建,并由 Hamza Amrouche 为 Symfony 4.X 进行分支和更新

Build Status

Coverage Status

Scrutinizer Code Quality

关于

这是一个由Twilio提供的官方SDK的包装器。

安装

将以下内容添加到您的composer.json文件中

"require": {
	"vresh/twilio-bundle": "dev-master",
}

将此包添加到app/AppKernel.php

$bundles = array(
	// ... other bundles
	new Vresh\TwilioBundle\VreshTwilioBundle(),
);

配置

将以下内容添加到您的config.yml文件中

vresh_twilio:
    #(Required) Your Account SID from www.twilio.com/user/account
    sid: 'XXXXXXXX'
    #(Required) Your Auth Token from www.twilio.com/user/account
    authToken: 'YYYYYYYY'
    #(Optional, default: '2010-04-01') Twilio API version
    version: '2010-04-01'
    #(Optional, default: 1) Number of times to retry failed requests
    retryAttempts: 3

用法

提供的服务

在控制器内部

class TelephoneController extends Controller
{
    public function callAction($me, $maybee)
    {
        //returns an instance of Vresh\TwilioBundle\Service\TwilioWrapper
    	$twilio = $this->get('twilio.api');

        $message = $twilio->account->messages->sendMessage(
	  '+14085551234', // From a Twilio number in your account
	  '+12125551234', // Text any number
	  "Hello monkey!"
	);

        //get an instance of \Service_Twilio
        $otherInstance = $twilio->createInstance('BBBB', 'CCCCC');

        return new Response($message->sid);
    }
}

在控制台命令内部

class SomeCommand extends ContainerAwareCommand
{
    protected function configure()
    {
        $this
            ->setName('some:comand')
            ->setDescription('A command')
        ;
    }

    protected function execute(InputInterface $input, OutputInterface $output)
    {
        //returns an instance of Vresh\TwilioBundle\Service\TwilioWrapper
        $twilio = $this->getContainer()->get('twilio.api');

        $message = $twilio->account->messages->sendMessage(
	  '+14085551234', // From a Twilio number in your account
	  '+12125551234', // Text any number
	  "Hello monkey!"
	);

        //get an instance of \Service_Twilio
        $otherInstance = $twilio->createInstance('BBBB', 'CCCCC');

        print $message->sid;

    }
}

版权 / 许可证

请参阅LICENSE