2
如何通過guzzle服務客戶端getCommand
函數獲取發佈數據?guzzle命令發佈數據
我的JSON如下所示:
"createMessage": {
"httpMethod": "POST",
"uri": "conversations/{conversation_id}/message",
"summary": "conversations by user",
"responseType": "class",
"responseClass": "\\Conversations\\Message",
"parameters": {
"conversation_id": {
"location": "uri",
"description": "conversation id",
"type": "integer"
},
"message": {
"location": "postField",
"sentAs": "message",
"type": "string"
}
}
}
然後我現在把我的文章數據,通過getCommand通過陣列的一部分:
$client = new \Guzzle\Service\Client();
$client->setDescription(\Guzzle\Service\Description\ServiceDescription::factory(__DIR__ . '/client.json'));
$command = $client->getCommand('createMessage', array('conversation_id' => 6, 'message' => 'test post message'));
它創造了新的記錄在數據庫中但發佈數據爲空,因此'message'
字段留空。
我已嘗試設置$client->setPostField('message', 'test post message');
但似乎不起作用。
感謝您成爲先鋒;) –