php通过CURL模拟get提交请求
方式一:
$host = "http://jisunews.market.alicloudapi.com";
$path = "/news/get";
$method = "GET";
$appcode = "0c4e883bc09f4d0e926136ecb65fcafa";
$headers = array();
array_push($headers, "Authorization:APPCODE " . $appcode);
$querys = "channel=".$channel."&num=40&start=0";
$bodys = "";
$url = $host . $path . "?" . $querys; $ch = curl_init();
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FAILONERROR, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
// curl_setopt($curl, CURLOPT_HEADER, true);
if ( == strpos("$".$host, "https://"))
{
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
}
$data = curl_exec($ch);
curl_close($ch);
方式二:
$urlCity = urlencode($cityName);
$url = 'restapi.amap.com/v3/config/district?keywords='.$urlCity.'&subdistrict=0&key=ebf76716220ae651fd505d8eb9812c37';
//初始化一个 cURL 对象
$ch = curl_init();
//设置你需要抓取的URL
curl_setopt($ch, CURLOPT_URL, $url);
// 设置cURL 参数,要求结果保存到字符串中还是输出到屏幕上。
curl_setopt($ch, CURLOPT_RETURNTRANSFER, );
//是否获得跳转后的页面
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, );
$data = curl_exec($ch);
curl_close($ch);
php通过CURL模拟get提交请求的更多相关文章
- php通过CURL模拟post提交请求
<?php header("Content-type:text/html;charset=utf-8"); class Test{ public function reque ...
- CURL 模拟http提交
1:CURL模拟get提交 private function httpGet($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_RETUR ...
- php中curl模拟post提交多维数组(转载)
原文地址:http://www.cnblogs.com/mingaixin/archive/2012/11/09/2763265.html 今天需要用curl模拟post提交参数,请求同事提供的一个接 ...
- 【转载】curl 模拟 GET\POST 请求,curl查看响应头 以及 curl post 上传文件
补充说明:curl查看响应头 curl -I "http://www.baidu.com"HTTP/1.1 200 OK #HTTP协议 HTTP 返回码Server: Tengi ...
- cURL模拟POST提交数据
首先,是这个代码: <?php //curl模拟post提交数据$url = "http://127.0.0.1/immoc/output.php";$post_data = ...
- php使用curl模拟多线程发送请求
每个PHP文件的执行是单线程的,但是php本身也可以用一些别的技术实现多线程并发比如用php-fpm进程,这里用curl模拟多线程发送请求.php的curl多线程是通过不断调用curl_multi_e ...
- [转]php模拟post提交请求,调用接口
本文转自:https://www.cnblogs.com/jiqing9006/p/3949190.html /** * 模拟post进行url请求 * @param string $url * @p ...
- php模拟post提交请求,调用接口
/** * 模拟post进行url请求 * @param string $url * @param string $param */ function request_post($url = '', ...
- php模拟post提交请求与调用接口
/** * 模拟post进行url请求 * @param string $url * @param string $param */ function request_post($url = '', ...
随机推荐
- 【原创】大数据基础之Logstash(2)应用之mysql-kafka
应用一:mysql数据增量同步到kafka 1 准备mysql测试表 mysql> create table test_sync(id int not null auto_increment, ...
- 用KendoGrid控件 快速做CRUD
先看效果: 主要引用的文件: <link href="/css/kendo/2014.1.318/kendo.common.min.css" rel="styles ...
- Flask允许跨域
什么是跨域 在 HTML 中,<a>, <form>, <img>, <script>, <iframe>, <link> 等标 ...
- 将文字数字转阿拉伯数字(Python)
今天改进爬虫的时候有这样的需求,如果是文字的数字把他转化成数字存储. 然后百度了一下没什么能看的博客. 其实挺无奈的,搜出来的博客全是一样的代码,有的图都是COPY,尤指CSDN,博客质量大多很差.怀 ...
- redhat7.3安装yum源
#检查rehat自带的yum源[root@localhost ~]# rpm -qa | grep yum -.el7.noarch -.el7.noarch -.el7.noarch -.el7.n ...
- css3 曲线阴影,翘边阴影
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8&quo ...
- mvn tomcat7:help的14个命令
D:\2018\code\XXX>mvn tomcat7:help [INFO] Scanning for projects... [INFO] [INFO] ----------------- ...
- Java_解惑
书名 ================================================================================================= ...
- Guideline 5.2.1 - Legal - Intellectual Property 解决方案
最近在上架公司公司项目的时候遇到这个问题什么5.2.1 然后去了解发现最近不少人都遇到了这个问题.先说一下 我上架的APP是一个医疗的APP然后说需要什么医疗资质,估计是账号的公司资质不够吧.后面和苹 ...
- UserNotifications ios10 通知使用
通知在ios10 中推荐使用 导入 import UserNotifications 头文件 if #available(iOS 10.0, *) { UNUserNotificationCent ...