用post和get的方式将数据提交到api
来源:互联网 发布:股票量化投资软件 编辑:程序博客网 时间:2024/06/04 21:46
function postData($url, $data)
{$ch = curl_init();
$timeout = 300;
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_REFERER, "http://www.jb51.net/"); //构造来路
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);
$handles = curl_exec($ch);
curl_close($ch);
return $handles;
}
将类转换为数组
function object_array($array)
{
if(is_object($array))
{
$array = (array)$array;
}
if(is_array($array))
{
foreach($array as $key=>$value)
{
$array[$key] = object_array($value);
}
}
return $array;
}
用get方式获取api的数据
$fp = fopen($url, 'r');
stream_get_meta_data($fp); //用fopen打开url, 以get方式获取内容:
while(!feof($fp)) {
$result .= fgets($fp, 1024);
}
echo "url body: $result";
- 用post和get的方式将数据提交到api
- 使用GET和POST方式将数据提交给服务器
- android中get方式和post方式提交数据到服务器的区别
- GET和POST提交数据方式的区别和使用
- GET和POST提交数据方式的区别和使用
- 数据提交方式:post和get
- Post和Get方式提交数据
- 数据提交方式:post和get
- <Basic>数据提交方式:post和get
- 使用get和post方式提交数据
- get和post方式提交数据的不同
- 提交数据的方式:GET与POST
- 表单的提交方式POST和GET
- Get和Post的提交方式
- HTTP POST和GET的提交方式
- 表单的提交方式:get和post
- get提交方式和post提交方式的区别
- 采用post的方式提交数据(无服务器) →采用get方式提交数据到服务器
- tcpdump命令介绍
- 构建webx简单应用
- InitializeCriticalSection
- Leetcode Remove Linked List Elements 删除链表中的元素
- 2015前端组件化框架之路
- 用post和get的方式将数据提交到api
- 正确配置java JDK的环境变量
- 关于排序——ruby版练手
- Redis 综述 [待整理]
- 什么是线程互斥
- sqoop入门
- .net学习之C#基础提高 3.基础知识
- 在jquery(1.7版)以及Ext(3.4版)中,查看在页面元素(domElement)上绑定的事件处理(listener、handler)
- linux中链接脚本ld文件详解