本文介绍了如何在 Zend_Rest_Client 中使用 POST 发送数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
还有下一段代码:
$client = new Zend_Rest_Client('http://test.com/rest');
$client->sendData('data');
如果我通过 GET
(echo $client->get()
) 发送,它工作正常
if i send via GET
(echo $client->get()
) it works correct
如果通过 POST
(echo $client->post()
) 我收到下一条消息未指定方法".
if via POST
(echo $client->post()
) i'm getting the next message "No Method Specified."
如何使用 Zend_Rest_Client
发送帖子?
how to send post using 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 中使用 POST 发送数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!