任何人都可以幫我提供一個使用 php5 和 AWS Appsync 或與 Appsync 一起使用的 php5 WebSocket 客戶端的 graphql 訂閱的工作示例嗎?我正在嘗試短信但沒有取得任何成功。<?phprequire(dirname(dirname(__FILE__)) . '/graphql/vendor/autoload.php');use WebSocket\Client;$query = <<<'GRAPHQL'subscription onCreateProfile{? onCreateBatch {? ? hotelId? ? batchId? ? profiles {? ? ? id? ? }? }}GRAPHQL;$appSyncURL = 'wss://pbnblnr7xxxxxxxxxxxx.appsync-realtime-api.ap-south-1.amazonaws.com/graphql';$context = stream_context_create();stream_context_set_option($context, 'ssl', 'verify_peer', false);stream_context_set_option($context, 'ssl', 'verify_peer_name', false);$client = new WebSocket\Client($appSyncURL, [? ? 'timeout' => 60, // 1 minute time out? ? 'context' => $context,? ? 'headers' => [? ? ? ? 'x-api-key' => 'APIKEY',? ? ],]);$client->send($query);echo $client->receive();$client->close();那么有人嘗試過使用 php5 進行 graphQL 訂閱嗎?我的要求是在 PHP 應用程序(后端)中使用 Graphql 訂閱。我知道 graphQL 訂閱可以通過 javascript WebSocket 客戶端在前端正常工作。但我必須在 PHP5 應用程序中使用 graphql 訂閱。
- 0 回答
- 0 關注
- 137 瀏覽
添加回答
舉報
0/150
提交
取消