How to send data via using POST in Zend_Rest_Client

柔情痞子 提交于 2019-12-13 12:08:08

问题


There is the next code:

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

if i send via GET (echo $client->get()) it works correct

if via POST (echo $client->post()) i'm getting the next message "No Method Specified."

how to send post using Zend_Rest_Client?


回答1:


Maybe this helps:

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



回答2:


Below is the link for the Zend_Rest_Client Class as it indicates we can use the public method restPost() to perform the post operation.

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



来源:https://stackoverflow.com/questions/4725471/how-to-send-data-via-using-post-in-zend-rest-client

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!