PHP code example of gulltour / aliyun

1. Go to this page and download the library: Download gulltour/aliyun library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gulltour / aliyun example snippets


'oss'=>[
         'class'=>'gulltour\aliyun\oss\AliyunOss',
         'bucket'=>'',
         'AccessKeyId' => '',
         'AccessKeySecret' => '',
         'ossServer' => '', //服务器外网地址,杭州为 http://oss-cn-hangzhou.aliyuncs.com
         'ossServerInternal' => '', //服务器内网地址,杭州为 http://oss-cn-hangzhou-internal.aliyuncs.com 如果为空则不走内网上传,内网上传会节省流量
         'imageHost' => '' //自定义资源域名 默认为 http://bucket.img-cn-hangzhou.aliyuncs.com/
     ],


Yii::$app->oss->upload2oss($filePath, $ssoPath);

Yii::$app->oss->getImageUrl($path, $style=null);


 'log'=>[
          'class'=>'aliyun\oss\AliyunLog',
          'logstore'=>'gulltour',
          'project'=>'',
          'AccessKeyId' => '',
          'AccessKeySecret' => '',
          'endpoint'=>'oss-cn-hangzhou.aliyuncs.com',
       ],


 'dayu'=>[
             'class'=>'gulltour\aliyun\aliyunDayu',
             'appKey' => '',
             'secretKey' => '',
             'signName' => '',
         ],



Yii::$app->dayu->smsSend($mobile, $params, $template);



'notificationMq' => [
            'class' => 'gulltour\aliyun\AliyunMQ',
            'endpoint' => 'http://publictest-rest.ons.aliyun.com',
            'topic' => 'kooeu_email_sms',
            'accessKeyId' => 'iEjugjCFUSBh1IXu',
            'accessKeySecret' => 'kvNO5lvWEBLGAEOJKfTWFjVJmWmMde',
            'producerGroup' => 'PID_HYW_Message',
            'consumerGroup' => 'CID_HYW_Message',
            'messageReceiver' => function($message) {echo $message;},
            'sentCallback' => function($message, $aliMsgID) {echo $message;echo $aliMsgID;},
]

Yii::$app->notificationMq->sendMessage('1234567891');

'mns'=>[
    'class'=>'gulltour\aliyun\aliyunMns',
    'accessId' => '',
    'accessKey' => '',
    'endpoint' => 'http://.mns.cn-beijing.aliyuncs.com/',
],

// 发送消息到队列
\Yii::$app->mns->sendMessage("QueueName", "content demo");
// 接收队列消息
$messageObject = \Yii::$app->mns->receiveMessage("QueueName");
$data = $messageObject->getMessageBody();
// 删除队列消息
\Yii::$app->mns->->deleteMessage('QueueName', $messageObject);
//publish 消息到主题
\Yii::$app->mns->publishMessage('TopicName', $data);
//订阅主题,在Yii2的 controller 中接收推送过来的数据
public function actionSubscribe()
{
	$message = \Yii::$app->request->getRawBody();
	$data = json_decode($message, true); //如果消息是JSON,PHP中需要转换成数组
}