//通过curl模拟post的请求;
function SendDataByCurl($url,$data=array()){
//对空格进行转义
$url = str_replace(' ','+',$url);
$ch = curl_init();
//设置选项,包括URL
curl_setopt($ch, CURLOPT_URL, "$url");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch,CURLOPT_TIMEOUT,3); //定义超时3秒钟
// POST数据
curl_setopt($ch, CURLOPT_POST, 1);
// 把post的变量加上
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data)); //所需传的数组用http_bulid_query()函数处理一下,就ok了-发送多维数组
//执行并获取url地址的内容
$output = curl_exec($ch);
$errorCode = curl_errno($ch);
//释放curl句柄
curl_close($ch);
if(0 !== $errorCode) {
return false;
}
return $output;
}

最新文章

  1. weui dialog
  2. LAMP环境
  3. Hibernate学习总结
  4. Codeforces Round #337 (Div. 2) D. Vika and Segments 线段树 矩阵面积并
  5. 谈谈Linux下动态库查找路径的问题
  6. Step by step Process of creating APD
  7. [Visual Studio Online] 移除Work Item(Feature、Backlog item、Task)
  8. jQuery信息提示工具jquery.poshytip (转载)
  9. C#中异步和多线程的区别
  10. datebox清除按钮,datebox加上清除按钮,easyui datebox加上清除按钮
  11. css中常用的标签
  12. Auto Install Workflow Manager 1.0
  13. linux系统安装iprouter
  14. 要重定向 IO 流,Process 对象必须将 UseShellExecute 属性设置为 False。
  15. static_cast 使用
  16. python练习题3:N的多次方
  17. 20165323 结对编程之四则运算week2-整体总结
  18. c++沉思录 学习笔记 第六章 句柄(引用计数指针雏形?)
  19. 20145308 《网络对抗》 MAL_后门应用与实践 学习总结
  20. HTML <frame> 标签的 src 属性

热门文章

  1. java面试基础篇-List
  2. [bzoj4977]跳伞求生<贪心>
  3. 通过jsDelivr + github 搭建一个简易图床
  4. 使用Cloudflare增强网站
  5. python 爬虫之 urllib 实践
  6. 工作中常用的Android系统ADB命令收集
  7. GitHub+PicGo构建免费图床及其高效使用
  8. Python Requests-学习笔记(4)-定制请求头和POST
  9. 通过Powershell检查SMTP地址是否被检测网站列入黑名单
  10. ftl中几个特殊的用法