方式一:

 $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提交请求的更多相关文章

  1. php通过CURL模拟post提交请求

    <?php header("Content-type:text/html;charset=utf-8"); class Test{ public function reque ...

  2. CURL 模拟http提交

    1:CURL模拟get提交 private function httpGet($url) { $curl = curl_init(); curl_setopt($curl, CURLOPT_RETUR ...

  3. php中curl模拟post提交多维数组(转载)

    原文地址:http://www.cnblogs.com/mingaixin/archive/2012/11/09/2763265.html 今天需要用curl模拟post提交参数,请求同事提供的一个接 ...

  4. 【转载】curl 模拟 GET\POST 请求,curl查看响应头 以及 curl post 上传文件

    补充说明:curl查看响应头 curl -I "http://www.baidu.com"HTTP/1.1 200 OK #HTTP协议 HTTP 返回码Server: Tengi ...

  5. cURL模拟POST提交数据

    首先,是这个代码: <?php //curl模拟post提交数据$url = "http://127.0.0.1/immoc/output.php";$post_data = ...

  6. php使用curl模拟多线程发送请求

    每个PHP文件的执行是单线程的,但是php本身也可以用一些别的技术实现多线程并发比如用php-fpm进程,这里用curl模拟多线程发送请求.php的curl多线程是通过不断调用curl_multi_e ...

  7. [转]php模拟post提交请求,调用接口

    本文转自:https://www.cnblogs.com/jiqing9006/p/3949190.html /** * 模拟post进行url请求 * @param string $url * @p ...

  8. php模拟post提交请求,调用接口

    /** * 模拟post进行url请求 * @param string $url * @param string $param */ function request_post($url = '', ...

  9. php模拟post提交请求与调用接口

    /** * 模拟post进行url请求 * @param string $url * @param string $param */ function request_post($url = '', ...

随机推荐

  1. Jenkins pipeline概念理解

      1.Jenkins Pipeline总体介绍 Pipeline,简而言之,就是一台运行于Jenkins上的工作流框架,将原本独立运行于单个或者多个节点的任务连接起来,实现单个任务难以完成的复杂流程 ...

  2. python bytes/str

    http://eli.thegreenplace.net/2012/01/30/the-bytesstr-dichotomy-in-python-3/

  3. LA 6893 矩阵HASH (模板)

    #include<stdio.h> #include<string.h> typedef unsigned long long ULL; ; ; int test,n,m,x, ...

  4. Vue -cli 入门 --项目搭建(一)

    一. 安装node.js环境. 在node.js官网下载稳定版本(https://nodejs.org/en/) 下载完成后点击安装,安装过程很简单,一直next即可,安装完成会自动添加node及np ...

  5. 查看当前APP打开的是哪个Activity

    按下 “window键+R键” 打开电脑的 “运行” 窗口,输入“cmd”,进入你的adb.exe所在的目录,输入 “ adb shell "dumpsys window | grep mC ...

  6. [转]phpstorm激活码注册码序列号

    浏览器打开 http://idea.lanyus.com/ , 点击页面中的“获得注册码”,然后在注册时切换至Activation Code选项,输入获得的注册码一长串字符串,就可以注册成功!(推荐方 ...

  7. response.setContentType()的String参数及对应类型

    response.addHeader("Content-Disposition", "attachment;filename="+ filename); res ...

  8. linux软件安装、rpm操作命令、本地yum配置(有什么用)

    1.yum是什么? yum的全称是yellow dog updater,modified,是一个shell前端软件包管理器;基于RPM包管理,能够从指定的服务器下载RPM包并自动安装,可以自动处理依赖 ...

  9. STM32应用实例十四:利用光敏二极管实现光度测量

    最近我们在开发臭氧发生器时,需要监测生成的臭氧的浓度,于是想到使用光度计来测量.因为不同浓度的臭氧对管的吸收作用是不相同的,于是检测光照强度的变化就可以得到相应的浓度数据. 1.硬件设计 此次光照度检 ...

  10. Confluence 6 安全概述和建议概述

    这个文档是针对 Confluence 的系统管理员希望对 Confluence Web应用程序安全性进行评估而设计的.这个页面将对系统的安全进行大致的描述,同时也会对 Confluence 的安全配置 ...