如何使用Zend_Rest_Client中的POST发送数据

时间:2011-01-18 14:50:48

标签: php zend-framework rest

有下一个代码:

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

如果我通过GETecho $client->get())发送,则说明工作正确

如果通过POST (echo $client->post())我收到下一条消息“没有指定方法。”

如何使用Zend_Rest_Client发送帖子?

2 个答案:

答案 0 :(得分:8)

也许这会有所帮助:

$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);

答案 1 :(得分:0)

以下是Zend_Rest_Client类的链接,因为它表明我们可以使用公共方法restPost()执行后期操作。

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

相关问题