如何在Cakephp做https post请求 [英] How to make https post request in Cakephp

查看:151
本文介绍了如何在Cakephp做https post请求的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要应用程序必须通过HTTPS POST进行REST API调用。我是cakephp的新人。我在想如果我可以使用httpsocket的https调用。

I have requirement where app has to make REST API calls over HTTPS POST. I am new to cakephp. I was thinking if I could do https calls using httpsocket.

感谢任何帮助。

谢谢。

推荐答案

如果您启用了PHP的Curl模块:

If you have PHP's Curl module enabled:

<?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
?>

这篇关于如何在Cakephp做https post请求的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆