PHP code example of baocaixiong / aliyun-mqs-lib

1. Go to this page and download the library: Download baocaixiong/aliyun-mqs-lib 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/ */

    

baocaixiong / aliyun-mqs-lib example snippets


$req = new \Mqs\Request\CreateQueue('queue-name');
$req->setDelaySeconds(x);
$req->setMaximumMessageSize(x);
// 如果参数已经组好了数组可以直接通过 $req->params($parameters) 设置属性;
$res = $req->send();
$res->isSuccess(); // => true

$req = new \Mqs\Request\SendMessage('queue-name');
$req->setMessageBody(xxx);
$req->setDelaySeconds(xxx);
$res = $req->send();
$res->isSuccess(); // => true 成功

$req = new \Mqs\Request\ReceiveMessage('queue-name');
$req->setWaitseconds(30);
$res = $req->send();
if ($res->isSuccess()) {
    $message = $res->getMessage(); // => \Mqs\Message
}
$messageBody = $message->getMessageBody();
// do something