如何在Cakephp中进行https发布请求
发布时间:2020-12-13 22:22:26 所属栏目:PHP教程 来源:网络整理
导读:我有要求应用程序必须通过HTTPS POST进行REST API调用.我是cakephp的新手.我在想是否可以使用httpsocket进行https调用. 我感谢任何帮助. 谢谢. 解决方法 如果您启用了 PHP的Curl模块: ?php// create a new cURL resource$ch = curl_init();$data = array('Y
我有要求应用程序必须通过HTTPS POST进行REST API调用.我是cakephp的新手.我在想是否可以使用httpsocket进行https调用.
我感谢任何帮助. 谢谢. 解决方法
如果您启用了
PHP的Curl模块:
<?php // create a new cURL resource $ch = curl_init(); $data = array('Your' => 'Data'); // set URL and other appropriate options curl_setopt($ch,CURLOPT_URL,"http://www.example.com/"); curl_setopt($ch,CURLOPT_POST,true); curl_setopt($ch,CURLOPT_POSTFIELDS,http_build_query($data)); // grab URL and pass it to the browser $result = curl_exec($ch); // close cURL resource,and free up system resources curl_close($ch); print_r($result); // output result for all the kings ?> (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |