regionId('cn-shanghai') ->asDefaultClient(); $result2 = ''; $msg = "{\"msg\":\"收款123元\"}"; try{ AlibabaCloud::rpc() ->product('Iot') // ->scheme('https') // https | http ->version('2018-01-20') ->action('Pub') ->method('POST') ->host('iot.cn-shanghai.aliyuncs.com') ->options([ 'query' => [ 'RegionId' => "cn-shanghai", 'TopicFullName' => "/a1ZSurIJmO0/BOX0000000000003/user/get", 'MessageContent' => base64_encode($msg), 'ProductKey' => "a1ZSurIJmO0", ], ]) ->request(); //var_dump($result2->toArray()); } catch (ClientException $e) { echo $e->getErrorMessage() . PHP_EOL; } catch (ServerException $e) { echo $e->getErrorMessage() . PHP_EOL; } //print_r($response); return ""; } // protected function getClient(){ // AlibabaCloud::accessKeyClient('LTAI4GJEWrN6dVh7HmPKHMyF', 'wMae4ckfVGwMQPVw5ZlVDDpihVeUap') // ->regionId('cn-shanghai') // ->asDefaultClient(); // $result = ''; // $msg = "{\"msg\":\"收款123元\"}"; // try{ // $result = AlibabaCloud::rpc() // ->product('Iot') // // ->scheme('https') // https | http // ->version('2018-01-20') // ->action('Pub') // ->method('POST') // ->host('iot.cn-shanghai.aliyuncs.com') // ->options([ // 'query' => [ // 'RegionId' => "cn-shanghai", // 'TopicFullName' => "/a1ZSurIJmO0/BOX0000000000003/user/get", // 'MessageContent' => base64_encode($msg), // 'ProductKey' => "a1ZSurIJmO0", // ], // ]) // ->request(); // var_dump($result->toArray()); // } catch (ClientException $e) { // echo $e->getErrorMessage() . PHP_EOL; // } catch (ServerException $e) { // echo $e->getErrorMessage() . PHP_EOL; // } // return $result; // } }