| <?php |
| |
| // This file is auto-generated, don't edit it. Thanks. |
| namespace RocketMQ\Eventbridge\SDK\Demo; |
| |
| use RocketMQ\Eventbridge\SDK\SDKClient; |
| use AlibabaCloud\Tea\Utils\Utils; |
| use AlibabaCloud\Tea\Console\Console; |
| use \Exception; |
| use AlibabaCloud\Tea\Exception\TeaError; |
| |
| use Darabonba\OpenApi\Models\Config; |
| use RocketMQ\Eventbridge\SDK\Models\PutEventsRequest; |
| |
| class Demo { |
| protected $_sdkClient; |
| |
| protected $_endpoint; |
| |
| public function __construct(){ |
| $this->_endpoint = "127.0.0.1:7001"; |
| $config = new Config([ |
| "endpoint" => $this->_endpoint |
| ]); |
| $this->_sdkClient = new SDKClient($config); |
| } |
| |
| /** |
| * EventData Controller apis: |
| * * putEvents * |
| * @return void |
| */ |
| public function testPutEvents(){ |
| $request = new PutEventsRequest([ |
| "eventBusName" => "demo-bus", |
| "event" => "an event for API test" |
| ]); |
| try { |
| $res = $this->_sdkClient->putEvents($request); |
| Console::log(Utils::toJSONString($res->body)); |
| } |
| catch (Exception $err) { |
| if (!($err instanceof TeaError)) { |
| $err = new TeaError([], $err->getMessage(), $err->getCode(), $err); |
| } |
| Console::log("err!"); |
| Console::log($err->message); |
| } |
| finally { |
| Console::log("test end!"); |
| } |
| } |
| } |