public function actionCurl(){

        $data['DATA']='{"NAME":"c","LEGEND":"c;c","GENDER":"","CITY":0,"BIRTHDAY":"","COMPANY":"","JOB":"","WEBSITE":"","ADDRESS":"","NOTE":"","CONTACTS":[],"IMS":[],"FLAGS":[]}';
$headers=array();
$headers[]='X-Requested-With:XMLHttpRequest';
$headers[]='Cookie:token=3cedf24b188fd7ac57176256a2a14879-b419e6ebb414d661a6e86a30cd633ce5; PHPSESSID=ddfrjb4p8evu3cumgnsveet2o3; _ga=GA1.2.1014541392.1437467254; _gat=1';
$headers[]='Referer:http://www.crm.com/newContact.php';
$headers[]='Content-Type:application/x-www-form-urlencoded; charset=UTF-8';
$headers[]='Content-Length:315';
$headers[]='Host:www.crm.com';
$headers[]='DNT:1';
$headers[]='Pragma:no-cache';
$headers[]='Connection:Keep-Alive';
$headers[]='User-Agent:Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.1; Trident/6.0)';
$headers[]='Accept:application/json, text/javascript, */*; q=0.01';
$headers[]='Accept-Encoding:gzip, deflate';
$headers[]='Accept-Language:zh-CN'; for ($i = 0; $i < 10; $i++) {
$res = $this->curls($data, 'http://www.crm.com/handler/handleAddContact.php ', 'POST', $headers);
print_r($res);
}
} /**
* curl请求
* @author lid
* @param array $data 要请求的array数组
* @param str $url 请求的地址
* @param str $method 大写 POST GET
* @param array $headers 扩展包头信息
* @return string
*/
public static function curls($data, $url, $method = 'POST', $headers = array()) { $ch = curl_init();
$method_upper = strtoupper($method);
if ($method_upper == 'POST') {
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($data));
} else {
$url = $url . (strpos($url, '?') ? '&' : '?') . (is_array($data) ? http_build_query($data) : $data);
curl_setopt($ch, CURLOPT_URL, $url);
}
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method_upper);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 20);
if ($headers) {
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
}
$tmpInfo = curl_exec($ch);
if (curl_errno($ch)) {
exit(curl_error($ch));
}
curl_close($ch);
return $tmpInfo;
}

CURLOPT_POSTFIELDS的这个设置中,亦可以直接发送数组的,但是这样做的后果是严重增加的请求的时间,耗时大约在2秒多,同样的操作用socket方式操作则正常,在毫秒级别。

数组:curl_setopt($ch, CURLOPT_POSTFIELDS, $arrData);
 修改为:curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($post_data));

http_build_query — 生成 URL-encode 之后的请求字符串。

curl 发送XML数据

$xml = ('<xml>
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don\'t forget me this weekend!</body>
</note></xml>');
$url = "https://wx.api.zf.com/wxnotify.php ";
$header[] = "Content-type: text/xml";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$res = curl_exec($ch);
curl_close($ch);

PHP CURL模拟提交数据 攻击N次方的更多相关文章

  1. curl模拟提交

    function curl_post($url, $post){ $options = array( CURLOPT_RETURNTRANSFER =>true, CURLOPT_HEADER ...

  2. php CURL 模拟 POST 提交数据

    <?php function liansuo_post($url,$data){ // 模拟提交数据函数 $curl = curl_init(); // 启动一个CURL会话 curl_seto ...

  3. php curl模拟post请求提交数据

    最近在做校园图书馆图书信息的采集程序,既然是图书馆图书的采集,肯定有提交搜索的页面,无非是post提交,让我想到了curl模拟提交,首先通过firebug进行抓包查询下post提交后的格式如下: tx ...

  4. 模拟提交API数据Pyqt版

    其实这个模拟提交数据之前已经写过篇: Python requests模拟登录 因为现在在做的项目中需要一个debug请求调试API,用PHP的CURL写了一个,又因Pyqt更能直观灵活的显示请求的参数 ...

  5. 在php中分别使用curl的post提交数据的方法和get获取网页数据的方法

    在php中分别使用curl的post提交数据的方法和get获取网页数据的方法整理分享一下额,具体代码如下: (1)使用php curl获取网页数据的方法: $ch=curl_init(); //设置选 ...

  6. PHP curl 模拟登陆

    一个比较好的类: $cookie_file=tempnam("C:/users","tmp");生成以以tmp为前缀的文件. <?php define ( ...

  7. php封装curl,模拟POST和GET请求HTTPS请求

    <?php /** * @title 封装代理请求 * @author victor **/ class ApiRequest { /** * curl提交数据 * @param String ...

  8. [转]php中 curl模拟post发送json并接收json

    本文转自:https://blog.csdn.net/pangchengyong0724/article/details/52103962 本地模拟请求服务器数据,请求数据格式为json,服务器返回数 ...

  9. php中 curl模拟post发送json并接收json(转)

    本地模拟请求服务器数据,请求数据格式为json,服务器返回数据也是json. 由于需求特殊性, 如同步客户端的批量数据至云端, 提交至服务器的数据可能是多维数组数据了.  这时需要将此数据以一定的数据 ...

随机推荐

  1. Object Removal by Exemplar-Based Inpainting 概括(附源码)

    关于这篇论文:其是采用基于样例的图像修复,通俗地讲就是图像其他部分的采样信息去填补遮挡区域,其与使用扩散方法的图像修补方法相比,不会产生模糊效应. 论文中涉及到的几个参数     Ω:要修补的区域 δ ...

  2. Maven 配置使用小技巧

    Spark开发中遇到了一些小问题,都是大神随便一个手指头帮我解决的.保持学习,积累吧! 一. 基于Intellij IDEA编辑器 1. 快捷键 注释/去注释   Ctrl+Shift+? 2. re ...

  3. bzoj4282慎二的随机数列

    海带头又上线了QwQ~ 这是一个奇怪的lis问题 显然一定存在一种最优答案使所有辨认不清的数都在答案中. [为什么呢]因为你完全可以用一个'N'来替换一个'K'啊QwQ~ 那么在选完所有'N'之后,一 ...

  4. 【bzoj4514】 Sdoi2016—数字配对

    http://www.lydsy.com/JudgeOnline/problem.php?id=4514 (题目链接) 题意 n个数,每个数值为a[i],有b[i]个,权值为c[i].若两个数能配对当 ...

  5. 使用IntelliJ IDEA 配置Maven(入门)

    1. 下载Maven 官方地址:http://maven.apache.org/download.cgi 解压并新建一个本地仓库文件夹 2.配置本地仓库路径   3.配置maven环境变量      ...

  6. fedora22命令useradd,groupadd等命令不能自动补全

    sudo ls -l /sbin/useradd 发现登陆账户没有读权限 修改为其他账户为读权限即可

  7. myeclipse给项目改了名字,但部署tomcat的项目名还是原来的

    如标题所示: 在myeclipse中按F2改了项目名称,之前在tomcat中部署的名称是另一个,再次重新部署,永远是上一个的旧名称 解决办法: 项目点右键-properties-左上角搜索框输入web ...

  8. 介绍对称加密算法,最常用的莫过于DES数据加密算法

    DES DES-Data Encryption Standard,即数据加密算法.是IBM公司于1975年研究成功并公开发表的.DES算法的入口参数有三个:Key.Data.Mode.其中Key为8个 ...

  9. Angular.js实现折叠按钮的经典指令.

    var expanderModule=angular.module('expanderModule',[]) expanderModule.directive('expander',function( ...

  10. [NHibernate]Nullables

    系列文章 [Nhibernate]体系结构 [NHibernate]ISessionFactory配置 [NHibernate]持久化类(Persistent Classes) [NHibernate ...