* CURL

http://www.php.net/manual/en/book.curl.php

http://jp2.php.net/manual/en/function.curl-setopt.php

GET:

<?php
/**
* Created by PhpStorm.
* User: Mch
* Date: 7/8/18
* Time: 16:02
*/
$ch = curl_init(); $url = 'http://www.tfjyzx.com/news/listTeacherByArea';
$params = [
'area' => '开封市',
'limit' => 6,
'type' => '学生'
]; function get_url($url, $params) {
$a = [];
foreach ($params as $name => $value) {
$a[] = $name .'=' .urlencode($value);
}
$url .= '?'.implode('&', $a);
return $url;
} $url = get_url($url, $params);
echo $url.PHP_EOL; curl_setopt_array($ch, [
CURLOPT_URL => $url,
CURLOPT_HEADER => 1,
CURLOPT_RETURNTRANSFER => 1
]); $data = curl_exec($ch);
curl_close($ch); echo $data.PHP_EOL;

  

http://www.tfjyzx.com/news/listTeacherByArea?area=%E5%BC%80%E5%B0%81%E5%B8%82&limit=6&type=%E5%AD%A6%E7%94%9F
HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Pragma: no-cache
Cache-Control: no-cache, no-store, max-age=0
Expires: Thu, 01 Jan 1970 00:00:00 GMT
Content-Type: application/json;charset=UTF-8
Content-Language: zh
Transfer-Encoding: chunked
Date: Sun, 08 Jul 2018 09:30:23 GMT

{"teacherList":[{"id":43,"name":"杜姝臻","url":null,"img":"./kaifeng33_img/studentView/4.jpg","school":"开封市33中","datetime":null,"intro":"三十三中优秀学生代表发言","content":null},{"id":42,"name":"朱彤","url":null,"img":"./kaifeng33_img/studentView/3.jpg","school":"开封市33中","datetime":null,"intro":"初二七班","content":null},{"id":41,"name":"张梦岩","url":null,"img":"./kaifeng33_img/studentView/2.jpg","school":"开封市33中","datetime":null,"intro":"三六班","content":null},{"id":40,"name":"周梦寒","url":null,"img":"./kaifeng33_img/studentView/1.jpg","school":"开封市33中","datetime":null,"intro":"三六班","content":null},{"id":20,"name":"程园林","url":null,"img":"./publish/students/kaifeng5/04.jpg","school":"开封市五中","datetime":null,"intro":"15届高三四","content":null},{"id":19,"name":"朱崇","url":null,"img":"./publish/students/kaifeng5/03.jpg","school":"开封市五中","datetime":null,"intro":"15届高三四 朱崇","content":null}]}

POST:

<?php
/**
* Created by PhpStorm.
* User: Mch
* Date: 7/8/18
* Time: 16:19
*/
$ch = curl_init(); $s = "POST /student/login HTTP/1.1
Host: www.tfjyzx.com
Connection: keep-alive
Content-Length: 48
Pragma: no-cache
Cache-Control: no-cache
Accept: application/json, text/javascript; q=0.01
Origin: http://www.tfjyzx.com
X-Requested-With: XMLHttpRequest
User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_11_6) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
Referer: http://www.tfjyzx.com/login.jsp
Accept-Encoding: gzip, deflate
Accept-Language: en-US,en;q=0.9,zh-CN;q=0.8,zh;q=0.7,ja;q=0.6
Cookie: experience=show; JSESSIONID=C63BF22874A3B791F212CFCBAFFAE432";
$header = explode("\n", $s); // http://jp2.php.net/manual/en/function.curl-setopt.php
curl_setopt_array($ch, [
CURLOPT_URL => 'http://118.190.150.189/student/login',
// TRUE to include the header in the output.
CURLOPT_HEADER => 1,
CURLOPT_RETURNTRANSFER => 1,
// TRUE to do a regular HTTP POST. This POST is the normal
// application/x-www-form-urlencoded kind, most commonly used by HTML forms.
CURLOPT_POST => 1,
CURLOPT_BINARYTRANSFER => 1,
CURLOPT_SAFE_UPLOAD => 1,
CURLOPT_HTTPHEADER => $header,
CURLOPT_POSTFIELDS => 'username=XXXXX150835&pwd=123456&captcha=&count=1', // phone number
/*
CURLOPT_POSTFIELDS => [
'username' => 'gmy12345',
'pwd' => '123456',
'captcha' => '',
'count' => 1
],
CURLOPT_ENCODING => 'gzip, deflate',
CURLOPT_COOKIE => 'experience=show; JSESSIONID=C63BF22874A3B791F212CFCBAFFAE432',
*/
CURLOPT_TIMEOUT => 5
]); $data = curl_exec($ch);
curl_close($ch); echo $data . PHP_EOL;

  

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Set-Cookie: JSESSIONID=AC471F40CDC460D6D7C14BAACAE21ED5; Path=/; HttpOnly
Content-Type: application/json;charset=UTF-8
Content-Length: 118
Date: Sun, 08 Jul 2018 09:32:30 GMT

{"result":1,"cause":"登录成功!","school":"濮阳市第八中学","sessionId":"AC471F40CDC460D6D7C14BAACAE21ED5"}

Sample Request Header:

Accept:*/*
Accept-Encoding:gzip, deflate, sdch
Accept-Language:zh-CN,zh;q=0.8,ja;q=0.6,en;q=0.4,ko;q=0.2,en-US;q=0.2,vi;q=0.2,fr;q=0.2,la;q=0.2
Connection:keep-alive
Host:192.168.10.137:9999
Origin:http://zhanghum:8088
Referer:http://zhanghum:8088/admin/index.html
User-Agent:Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/57.0.2987.133 Safari/537.36

Sample Response header:

Access-Control-Allow-Credentials:true
Access-Control-Allow-Origin:http://zhanghum:8088
Content-Encoding:gzip
Content-Type:application/json
Date:Mon, 16 Jul 2018 02:03:12 GMT
Transfer-Encoding:chunked
Vary:Accept-Encoding

最新文章

  1. springMVC 学习(一)
  2. jmeter agent配置
  3. ArrayBlockingQueue跟LinkedBlockingQueue的区别
  4. C# 引用SHDocVw 实现模拟网页操作
  5. 关于javascript输出中文乱码的问题
  6. hdu 5113 Black And White
  7. 对发给Application.Handle消息的三次执行(拦截)消息的过程
  8. 制作OB图的时候,OB玩家进入后就退出的问题
  9. mybatis 入门进阶之 pojo
  10. ural1523 K-inversions
  11. CVS简介
  12. 【Android应用开发】Android Studio 错误集锦 -- 将所有的 AS 错误集合到本文
  13. CTF资料
  14. plink, vcftool计算等位基因频率(allele frequency,vcf)
  15. LeetCode - 386. Lexicographical Numbers
  16. json - 内容中需处理的特殊字符(转)
  17. MFC中设备描述表dc的使用
  18. 【C】——可变参数
  19. angular2+ 初理解
  20. 如何使用socket进行java网络编程(四)

热门文章

  1. 剑指 Offer 61. 扑克牌中的顺子
  2. WebAPI 自定义过滤
  3. await 关键字 后面跟Task 和Task &lt;T&gt;
  4. springgateway
  5. redis集群访问,重启,关闭,带密码访问集群
  6. ES6 class——name属性与new.target属性
  7. springboot系列总结(一)---初识springboot
  8. 在EXCEL中,判断同列数据重复,并标识出来
  9. Nginx配置文件详解与优化建议
  10. Nginx从安装到虚拟主机、https加密、重定向的设置