$postData = "reqType=2&caller=15088719619&called=15068722845";
$result = send_post("192.168.0.152","4569","http://192.168.0.152:4569",$postData);
var_dump($result); function send_post($host,$port,$urlPage,$postData){
// echo str_pad(" ", 256); $errno = '';
$errstr = ''; $length = strlen($postData); $fp = fsockopen($host,$port,$errno,$errstr,120) or exit($errstr."--->".$errno);
//构 造post请求的头
$header = "POST $urlPage HTTP/1.1\r\n";
$header .= "Host:".$host."\r\n";
$header .= "Referer:".$urlPage."\r\n";
$header .= "Content-Type:application/x-www-form-urlencoded\r\n";
$header .= "Content-Length:".$length."\r\n";
$header .= "Connection:Close\r\n\r\n";
//添加post的字符串
$header .= $postData."\r\n"; //发送post的数据
fputs($fp, $header);
// $inheader = 1; $result = array(); //最终输出结果;
$temp = "";
$flag = 0;
$readLen = 128;
while (!feof($fp)){ $line = fread($fp,$readLen); // 去除请求包的头只显示页面 的返回数据 (注意fgets fread($fp,1)最少2个字节起。)
$temp .= $line; /* echo $line;
my_flush();
if($inheader && ($line == "\n" || $line == "\r\n"))
$inheader = 0; if($inheader==0){ $temp .= trim($line);
} */
if(strlen($line)<$readLen){
break;
} } fclose($fp); $result = formatResponeData($temp); return $result; } function formatResponeData($data){ $resultArr = explode("\r\n\r\n", $data); return trim($resultArr[1]); } function my_flush(){
ob_flush();
flush();
}

php接口post提交方法 (改良版)的更多相关文章

  1. php接口post提交方法 。

    方法一,用 file_get_contents function send_post($url, $post_data) { //$postdata = http_build_query($post_ ...

  2. C# 你什么让程序员寂寞成酱紫 (男生版 娱乐中学习 抽象类 接口 继承 实现方法 )

    你什么让程序员寂寞成酱紫 (男生版 娱乐中学习 抽象类 接口 继承 实现方法 )   一个家庭 相当于 一个空间,这个空间里 有 很多元素,比如 爱,爱这个抽象事物,可能有很多动作,接吻.交流,对于一 ...

  3. Loadrunner Http接口Get/Post方法性能测试脚本解析

    最近使用LoadRunner 11进行了一次完整的Http WEB接口性能测试,下面介绍下Http接口Get/Post方法性能测试脚本通用编写方法. 1. Http接口性能测试基本流程 首先定义了一个 ...

  4. 详解OJ(Online Judge)中PHP代码的提交方法及要点【举例:ZOJ 1001 (A + B Problem)】

    详解OJ(Online Judge)中PHP代码的提交方法及要点 Introduction of How to submit PHP code to Online Judge Systems  Int ...

  5. 优化改良版:数组,List,等集合需要加逗号或其它符合转成字符串

    大家经常需要数组加逗号拼接成字符串的情况传统作法就是写for,foreach拼接, 现给出优化改良版数组,List,等集合需要加逗号或其它符合转成字符串方法: List<string> l ...

  6. C# 索引器,实现IEnumerable接口的GetEnumerator()方法

    当自定义类需要实现索引时,可以在类中实现索引器. 用Table作为例子,Table由多个Row组成,Row由多个Cell组成, 我们需要实现自定义的table[0],row[0] 索引器定义格式为 [ ...

  7. AJAX提交方法(POST)Demon

    AJAX的POST提交方法,本质上来看和GET差不多,有些细小的区别,POST要提交数据时,需要setRequestHeader()方法来提交HTTP头,然后send()方法中提交数据(格式为:&qu ...

  8. 通过实现System.IComparable接口的CompareTo方法对两个类进行比较

    假设现在有一个学生类 class Student { int age; public Student(int age) { this.age = age; } } 要使学生类之间能进行比较,实现Sys ...

  9. ICompare接口、Sort()方法

    1.接口中的方法并不实现具体功能,继承于该接口的类必须实现具体功能. 核心思想:对修改封闭,对扩展开放. 2.Sort()方法: 默认:Sort(内容) 英文:按照首字母顺序排序,首字母相同则看第二个 ...

随机推荐

  1. web前端基础篇④

    1.BFC-块级元素-块级格式化上下文布局规则:独立区域,与外部毫不相关内部box会在垂直方向,一个个放置box垂直方向距离由margin决定BFC的区域不会与float box重叠计算BFC高度时, ...

  2. H.264 / MPEG-4 Part 10 White Paper-翻译

    1. Introduction Broadcast(广播) television and home entertainment(娱乐) have been revolutionised(彻底改变) b ...

  3. 网页设计、java、Andorid资源清单整理

    多学多练做笔记很重要. 赤裸裸的干货非鸡汤 网页设计的主要技术:    Html,    Js,    Css,    Ps       HTML/HTML5     网页的基础Html必须知道的.但 ...

  4. Nice Sequence_线段树***

    Description Let us consider the sequence a1, a2,..., an of non-negative integer numbers. Denote as c ...

  5. Android 学习第4课,一些小知识

    java语言的注释有如下3种: 1. // 2./* 注释内容 */ 3./**     注释内容    */       这种叫文档注释,这种注释常被javaDoc文档工具读取作为 JavaDoc文 ...

  6. ex26 纠正练习

    题目中给出的代码如下: def break_words(stuff): """This function will break up words for us." ...

  7. bigworld源码分析(4)——BaseAppMgr分析

    BaseAppMgr是用来管理BaseApp的,在整个bigworld中只有一个.本篇就BaseAppMgr的一些核心功能进行分析: (1) BaseAppMgr是如何通知BaseApp创建Entit ...

  8. python数据结构与算法——二叉树结构与遍历方法

    先序遍历,中序遍历,后序遍历 ,区别在于三条核心语句的位置 层序遍历  采用队列的遍历操作第一次访问根,在访问根的左孩子,接着访问根的有孩子,然后下一层 自左向右一一访问同层的结点 # 先序遍历 # ...

  9. Objective-c——UI基础开发第十一天(UICollectionView)

    一.知识点 1.UICollectionView的dataSource .delegate 2.UICollectionView多组数据和单组数据的展示 3.UICollectionView.UICo ...

  10. CE选择目录对话框(转)

    本文转载于http://blog.163.com/zhaojun_xf/blog/static/30050580201132221118479/ 在Wince下要打开目录对话框需要调用函数SHBrow ...