簡體   English   中英

如何使用Zend_Rest_Client中的POST發送數據

[英]How to send data via using POST in Zend_Rest_Client

有下一個代碼:

$client = new Zend_Rest_Client('http://test.com/rest');
$client->sendData('data');

如果我通過GET發送( echo $client->get() )它的工作正確

如果通過POST (echo $client->post() )我收到下一條消息“No Method Specified”。

如何使用Zend_Rest_Client發送帖子?

也許這有助於:

$base_url = 'http://www.example.com';
$endpoint = '/path/to/endpoint';
$data = array(
    'param1' => 'value1',
    'param2' => 'value2',
    'param3' => 'value3'
);
$client = new Zend_Rest_Client($base_url);
$response = $client->restPost($endpoint, $data);
print_r($response);

下面是Zend_Rest_Client類的鏈接,因為它表明我們可以使用公共方法restPost()來執行post操作。

restPost ($path, $data=null)
Performs an HTTP POST request to $path. 

http://www.sourcecodebrowser.com/zend-framework/1.10.3/class_zend_ rest _client.html

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM