我有一个要求,应用程序必须通过 HTTPS POST 进行 REST API 调用。我是 cakephp 的新手。我在想是否可以使用 httpsocket 进行 https 调用。
我很感激任何帮助。
Thanks.
您可以使用其中任何一个
CAKEPHP SOCKET
// Use either of the following two:
App::import('Core', 'HttpSocket'); // Cake 1.x
App::uses('HttpSocket', 'Network/Http'); // Cake 2.x
$HttpSocket = new HttpSocket();
$results = $HttpSocket->post('www.somesite.com/add', array('name' => 'test', 'type' => 'user'));
//$results contains what is returned from the post.
CURL
$url = 'http://domain.com/get-post.php';
$fields = 'var1=value1&var2=value2';
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$url);
curl_setopt($ch,CURLOPT_POST,count($fields));
curl_setopt($ch,CURLOPT_POSTFIELDS,$fields_string);
$result = curl_exec($ch);
curl_close($ch);
JAVASCRIPT
如果您希望在客户端完成此操作
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)