-xml_id=72这o2o是什么意思思?

http:///flashApp/p2v_blog.11.05.13.swf?xml_id=&auto_start=1 这是什么歌呢_百度知道
http:///flashApp/p2v_blog.11.05.13.swf?xml_id=&auto_start=1 这是什么歌呢
提问者采纳
Michelle Branch - here with me试听载
提问者评价
来自团队:
其他类似问题
为您推荐:
其他1条回答
Michelle Branch - here with me
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁Android视图开发中,layer-list\item\clip\shape等标签对应不同的Drawable对象,是什么意思?_百度知道
Android视图开发中,layer-list\item\clip\shape等标签对应不同的Drawable对象,是什么意思?
提问者采纳
shapeselectorAndroid UI设计经用比我要自定义圆角Button点击Button些效变化要用shapeselector说shapeselector美化控件作用至关重要1.Shape简介作用:XML定义几何形状位置:res/drawable/文件名称.xml使用:Java代码:R.drawable.文件名称XML:Android:background=&@drawable/文件名称&属性:&shape&
Android:shape=[&rectangle& | &oval& | &line& | &ring&]其rectagle矩形oval椭圆line水平直线ring环形&shape&节点用属性:&gradient&
渐变Android:startColor
起始颜色Android:endColor
Android:angle
渐变角度<img class="word-replace" src="/api/getdecpic?picenc=0ad<img class="word-replace" src="/api/getdecpic?picenc=0ad表示左右数值45整数倍默认0;Android:type
渐变式 liner线性渐变 radial环形渐变 sweep&solid &
填充Android:color
填充颜色&stroke & 描边Android:width 描边宽度Android:color 描边颜色Android:dashWidth 表示&#39;-&#39;横线宽度Android:dashGap 表示&#39;-&#39;横线间距离&corners & 圆角Android:radius
圆角半径 值越角越圆Android:topRightRadius
右圆角半径Android:bottomLeftRadius 右圆角角半径Android:topLeftRadius 左圆角半径Android:bottomRightRadius 左圆角半径&padding &填充android:bottom=&1.0dip& 底部填充android:left=&1.0dip& 左边填充android:right=&1.0dip& 右边填充android:top=&0.0dip& 面填充2.Selector简介根据同选定状态定义同现实效四属性:android:state_selected选android:state_focused获焦点android:state_pressed点击android:state_enabled设置否响应事件,指所事件android:state_window_focused默认背景图片引用位置:res/drawable/文件名称.xml使用:Java代码:R.drawable.文件名称XML:Android:background=&@drawable/文件名称&[java] view plaincopy&?xml version=&1.0& encoding=&utf-8& ?&
&selector xmlns:Android=&&&
&!-- 默认背景图片--&
&item Android:drawable=&@drawable/pic1& /&
&!-- 没焦点背景图片 --&
Android:state_window_focused=&false&
android:drawable=&@drawable/pic_blue&
&!-- 非触摸模式获焦点并单击背景图片 --&
Android:state_focused=&true&
android:state_pressed=&true&
android:drawable= &@drawable/pic_red&
&!-- 触摸模式单击背景图片--&
Android:state_focused=&false&
Android:state_pressed=&true&
Android:drawable=&@drawable/pic_pink&
&!--选图片背景--&
Android:state_selected=&true&
android:drawable=&@drawable/pic_orange&
&!--获焦点图片背景--&
Android:state_focused=&true&
Android:drawable=&@drawable/pic_green&
&/selector&
3.layer-list
简介:图片或面两种效按照顺序层叠起例:[java] view plaincopy&?xml version=&1.0& encoding=&UTF-8&?&
&layer-list
xmlns:android=&&&
&!--图片1--&
&item android:id=&@+id/user_faceback_drawable&
android:drawable=&@drawable/faceback& /&
&!--图片2--&
&item android:id=&@+id/user_face_drawable&
android:drawable=&@drawable/h001&
android:left=&10.0dip&
android:top=&18.0dip&
android:right=&25.0dip&
android:bottom=&35.0dip& /&
&/layer-list&
&!--2图片叠加--&
提问者评价
来自团队:
其他类似问题
为您推荐:
android的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁mybatis 配置文件文件中 &![cdata[ ${value} ]]& 是什么意思_百度知道
mybatis 配置文件文件中 &![cdata[ ${value} ]]& 是什么意思
&update id = &excute& parameterType=&java.lang.String&&
&![CDATA[ ${value}]]&&&#47;update&请问 &![CDATA[ ${value}]]& 意思 要用${value} 取传入变量种写#{id} 两种区别&select id = &excute& parameterType=&java.lang.String&&select * from student where id = #{id}&&#47;select &两种取变量式啊用#{} 用${} 用区别请高手解释
#能做数据类型匹配$则像&![CDATA[ ${value}]]& valuesql语句态sql语句终执行条sql语句select * from student where id = #{id} id传入sql语句查询值
select * from student where id = #{id} 如果你这个id也传入个sql语句,这里就会把它当成一个查询值了?是什么意思?假如说我id传入的一个参数 session.selectList(&queryAllStudent&, &(select id from student where name = &#39;zs&#39; )& );#{id}
${id} 分别会对他怎么处理?
#select * from student where id =select id from student where name = &#39;zs&#39; 如果id是数值型,会报错。$select * from student where id =select id from student where name = &#39;zs&#39; )这里应该是sql错误了
其他类似问题
为您推荐:
其他1条回答
value能包含xml格式东西&![CDATA[ ....]]&,xml表示该部内容xml解析器解析
cdata的相关知识
等待您来回答
下载知道APP
随时随地咨询
出门在外也不愁你的浏览器禁用了JavaScript, 请开启后刷新浏览器获得更好的体验!
// error_reporting(0);
* 微信公共平台整合库
* @author Ligboy ()
* @license 本库的很多思路来自于网上的其他热心人士的贡献,大家任意使用,我本人放弃所有权利,如果您心情好,给我留个署名也行。
interface WechatSessionToolInter {
* @name 获取token
function getToken();
* @name 设置保存token
* @param string $token
function setToken($token);
* @name 获取Cookies
function getCookies();
* @name 设置保存Cookies
* @param string $Cookies
function setCookies($Cookies);
* @author Ligboy
* @name 微信关联接口
interface WechatAscToolInter {
* @name 判断指定Openid是否关联
* @param string $Openid 指定Openid
* @return boolean 返回逻辑判断结果,已关联则返回用户信息数组
function getAscStatusByOpenid($Openid);
* @name 判断指定fakeid是否关联
* @param string $fakeid 指定fakeid
* @return boolean 返回逻辑判断结果,已关联则返回用户信息数组
function getAscStatusByFakeid($fakeid);
* @name 设置fakeid与Openid的关联
* @param string $openid Openid
* @param string $fakeid fakeid
* @param string $detailInfo $detailInfo
function setAssociation($openid, $fakeid, $detailInfo);
interface WechatFollowToolInter {
* @name 用户关注执行动作
* @param string $openid Openid
function followAddAction($openid);
* @name 取消关注执行动作
* @param string $openid Openid
function followCancelAction($openid);
class Wechat {
/ 配置参数
* @var array
* @example array('token'=&'微信接口密钥','account'=&'微信公共平台账号','password'=&'微信公共平台密码','webtoken'=&&微信公共平台网页url的token&);
private $wechatOptions=array('token'=&'rqerwer','account'=&'','password'=&'wwwwww'); //
private $cookiefilepath = &&; //以文件形式保存cookie的保存目录,肯定是可写的
public $webtoken = '';
private $webtokenStoragefile = &&;
//微信公共平台的token存储文件,就是公共平后台网页的token
public $debug =
//调试开关
public $protocol = &https&;
//使用协议类型 http or
/ 静态常量 /
const MSGTYPE_TEXT = 'text';
const MSGTYPE_IMAGE = 'image';
const MSGTYPE_LOCATION = 'location';
const MSGTYPE_LINK = 'link';
const MSGTYPE_EVENT = 'event';
const MSGTYPE_MUSIC = 'music';
const MSGTYPE_NEWS = 'news';
const MSGTYPE_VOICE = 'voice';
const MSGTYPE_VIDEO = 'video';
/ 私有参数 /
private $_
private $_funcflag =
private $_
private $_
private $_getRevRunOnce = 0;
private $_
private $_wechatcallbackFuns =
private $_curlHttpObject =
* @var boolean 自动附带发送openid开关
private $_autosendopenid =
* @var boolean 被动响应关联动作开关
private $_passiveAssociationSwitch =
* @var boolean 被动响应关联动作开关
private $_passiveAscGetDetailSwitch =
* 初始化工作
* @param array $option
array('token'=&'微信接口密钥','account'=&'微信公共平台账号','password'=&'微信公共平台密码');
function __construct($option=array())
if (!empty($option))
$this-&wechatOptions = array_merge($this-&wechatOptions, $option);
* @name 主动动作初始化
* @return Wechat
function positiveInit()
if (!is_object($this-&_wechatcallbackFuns)) {
if ($this-&wechatOptions['wechattool']) {
$this-&setWechatToolFun($this-&wechatOptions['wechattool']);
$this-&setWechatToolFun($this-&wechatOptions['wechattool']);
$this-&_cookies = $this-&getCookies();
$this-&webtoken = (string)$this-&getToken();
private function curlInit($type=null, $option=null) {
if (!isset($this-&_curlHttpObject)) {
$this-&_curlHttpObject = new CurlHttp();
if (&single&==$type) {
$this-&_curlHttpObject-&singleInit($option);
elseif (&roll&==$type){
$this-&_curlHttpObject-&rollInit($option);
return $this-&_curlHttpO
* 验证请求签名操作
* @return boolean
private function checkSignature()
$signature = $_GET[&signature&];
$timestamp = $_GET[&timestamp&];
$nonce = $_GET[&nonce&];
$token = $this-&wechatOptions['token'];
$tmpArr = array($token, $timestamp, $nonce);
sort($tmpArr);
$tmpStr = implode( $tmpArr );
$tmpStr = sha1( $tmpStr );
if( $tmpStr == $signature )
* 验证当前请求是否有效
* @param bool $return 是否返回
public function valid($return=false)
$echoStr = isset($_GET[&echostr&]) ? $_GET[&echostr&]: '';
if ($return)
if ($echoStr)
if ($this-&checkSignature())
return $echoS
return $this-&checkSignature();
if ($echoStr)
if ($this-&checkSignature())
die($echoStr);
die('no access');
if ($this-&checkSignature())
die('no access');
* 设置发送消息
* @param array $msg 消息数组
* @param bool $append 是否在原消息数组追加
public function Message($msg = '',$append = false){
if (is_null($msg)) {
$this-&_msg =array();
}elseif (is_array($msg)) {
if ($append)
$this-&_msg = array_merge($this-&_msg,$msg);
$this-&_msg = $
return $this-&_
return $this-&_
public function setFuncFlag($flag) {
$this-&_funcflag = $
private function log($log){
if ($this-&debug && function_exists($this-&_logcallback)) {
if (is_array($log)) $log = print_r($log,true);
return call_user_func($this-&_logcallback,$log);
* @name 获取微信服务器发来的信息
* @return mixed
public function getRev()
$postStr = file_get_contents(&php://input&);
$this-&log($postStr);
if (!empty($postStr))
$this-&_receive = (array)simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
if ($this-&_getRevRunOnce==0) {
$event = $this-&getRevEvent();
if (Wechat::MSGTYPE_EVENT==$this-&getRevType())
if ($event['event']==&subscribe& && method_exists($this-&_wechatcallbackFuns, &followAddAction&)) {
$this-&_wechatcallbackFuns-&followAddAction($this-&getRevFrom());
elseif ($event['event']==&unsubscribe& && method_exists($this-&_wechatcallbackFuns, &followCancelAction&)){
$this-&_wechatcallbackFuns-&followCancelAction($this-&getRevFrom());
$this-&doAssociationAction();
$this-&_getRevRunOnce = 1;
* 获取消息发送者
* @return string or boolean
public function getRevFrom()
if ($this-&_receive)
return $this-&_receive['FromUserName'];
* 获取消息接受者
* @return string or boolean
public function getRevTo()
if ($this-&_receive)
return $this-&_receive['ToUserName'];
* 获取接收消息的类型
public function getRevType()
if (isset($this-&_receive['MsgType']))
return $this-&_receive['MsgType'];
* 获取消息ID
public function getRevID() {
if (isset($this-&_receive['MsgId']))
return $this-&_receive['MsgId'];
* 获取消息发送时间
public function getRevCtime() {
if (isset($this-&_receive['CreateTime']))
return $this-&_receive['CreateTime'];
* 获取接收消息内容正文
public function getRevContent(){
if (isset($this-&_receive['Content']))
return $this-&_receive['Content'];
* 获取接收消息图片
public function getRevPic(){
if (isset($this-&_receive['PicUrl']))
return $this-&_receive['PicUrl'];
* 获取接收消息链接
public function getRevLink(){
if (isset($this-&_receive['Url'])){
return array(
'url'=&$this-&_receive['Url'],
'title'=&$this-&_receive['Title'],
'description'=&$this-&_receive['Description']
* 获取接收地理位置
* @return array('x'=&'','y'=&'','scale'=&'','label'=&'')
public function getRevGeo(){
if (isset($this-&_receive['Location_X'])){
return array(
'x'=&$this-&_receive['Location_X'],
'y'=&$this-&_receive['Location_Y'],
'scale'=&$this-&_receive['Scale'],
'label'=&$this-&_receive['Label']
* 获取接收事件推送
* @return array 成功返回事件数组,失败返回false
public function getRevEvent(){
if (isset($this-&_receive['Event'])){
return array(
'event'=&$this-&_receive['Event'],
'key'=&$this-&_receive['EventKey'],
* 获取接收语言推送
public function getRevVoice(){
if (isset($this-&_receive['MediaId'])){
return array(
'mediaid'=&$this-&_receive['MediaId'],
'format'=&$this-&_receive['Format'],
private static function xmlSafeStr($str)
return '&![CDATA['.preg_replace(&/[\\x00-\\x08\\x0b-\\x0c\\x0e-\\x1f]/&,'',$str).']]&';
* 数据XML编码
* @param mixed $data 数据
* @return string
private static function data_to_xml($data) {
$xml = '';
foreach ($data as $key =& $val) {
is_numeric($key) && $key = &item id=\&$key\&&;
( is_array($val) || is_object($val)) ? self::data_to_xml($val)
: self::xmlSafeStr($val);
list($key, ) = explode(' ', $key);
&&/$key&&;
* @param mixed $data 数据
* @param string $root 根节点名
* @param string $item 数字索引的子节点名
* @param string $attr 根节点属性
* @param string $id
数字索引子节点key转换的属性名
* @param string $encoding 数据编码
* @return string
private function xml_encode($data, $root='xml', $item='item', $attr='', $id='id', $encoding='utf-8') {
if(is_array($attr)){
$_attr = array();
foreach ($attr as $key =& $value) {
$_attr[] = &{$key}=\&{$value}\&&;
$attr = implode(' ', $_attr);
= trim($attr);
= empty($attr) ? '' : & {$attr}&;
.= &&{$root}{$attr}&&;
.= self::data_to_xml($data, $item, $id);
.= &&/{$root}&&;
* 设置回复消息
* Examle: $obj-&text('hello')-&reply();
* @param string $text
public function text($text='')
if ($this-&_autosendopenid) {
if (is_object($this-&_wechatcallbackFuns) && method_exists($this-&_wechatcallbackFuns, &getAscStatusByOpenid&)) {
if (!$this-&_wechatcallbackFuns-&getAscStatusByOpenid($this-&getRevFrom())) {
$text .= &&a href=\&&.$this-&getRevFrom().&\&& &/a&&;
$text .= &&a href=\&&.$this-&getRevFrom().&\&& &/a&&;
$FuncFlag = $this-&_funcflag ? 1 : 0;
$msg = array(
'ToUserName' =& $this-&getRevFrom(),
'FromUserName'=&$this-&getRevTo(),
'MsgType'=&self::MSGTYPE_TEXT,
'Content'=&$text,
'CreateTime'=&time(),
'FuncFlag'=&$FuncFlag
$this-&Message($msg);
* 设置回复音乐
* @param string $title
* @param string $desc
* @param string $musicurl
* @param string $hgmusicurl
public function music($title,$desc,$musicurl,$hgmusicurl='') {
$FuncFlag = $this-&_funcflag ? 1 : 0;
$msg = array(
'ToUserName' =& $this-&getRevFrom(),
'FromUserName'=&$this-&getRevTo(),
'CreateTime'=&time(),
'MsgType'=&self::MSGTYPE_MUSIC,
'Music'=&array(
'Title'=&$title,
'Description'=&$desc,
'MusicUrl'=&$musicurl,
'HQMusicUrl'=&$hgmusicurl
'FuncFlag'=&$FuncFlag
$this-&Message($msg);
* 设置回复图文
* @param array $newsData
* @example 数组结构:
[0]=&array(
'Title'=&'msg title',
'Description'=&'summary text',
'PicUrl'=&'/1.jpg',
'Url'=&'/1.html'
public function news($newsData=array())
$FuncFlag = $this-&_funcflag ? 1 : 0;
$count = count($newsData);
$msg = array(
'ToUserName' =& $this-&getRevFrom(),
'FromUserName'=&$this-&getRevTo(),
'MsgType'=&self::MSGTYPE_NEWS,
'CreateTime'=&time(),
'ArticleCount'=&$count,
'Articles'=&$newsData,
'FuncFlag'=&$FuncFlag
$this-&Message($msg);
* 向微信服务器回复消息
* Example: $this-&text('msg tips')-&reply();
* @param string $msg 要发送的信息, 默认取$this-&_msg
* @param bool $return 是否返回信息而输出
默认:false
public function reply($msg=array(),$return = false)
if (empty($msg))
$msg = $this-&_
$this-&xml_encode($msg);
$this-&log($xmldata);
if ($return)
//debug 调试记录回复信息
if ($this-&debug){file_put_contents($this-&debugpath.&./reply.txt&,&\n---&.date('Y-m-d H:i:s').&\n&.$xmldata,FILE_APPEND);}
* 登录微信公共平台,获取并保存cookie、webtoken到指定文件
* @return mixed 成功则返回true,失败则返回失败
public function login(){
$url = $this-&protocol.&://mp./cgi-bin/login?lang=zh_CN&;
$postfields[&username&] = $this-&wechatOptions['account'];
$postfields[&pwd&] = md5($this-&wechatOptions['password']);
$postfields[&f&] = &json&;
$postfieldss = &username=&.urlencode($this-&wechatOptions['account']).&&pwd=&.urlencode(md5($this-&wechatOptions['password'])).&&f=json&;
$this-&curlInit(&single&);
$response = $this-&_curlHttpObject-&post($url, $postfields, $this-&protocol.&://mp./cgi-bin/login&, $this-&_cookies);
$result = json_decode($response, true);
if ($result['ErrCode']==&65201&||$result['ErrCode']==&65202&||$result['ErrCode']==&0&)
preg_match('/&token=([\d]+)/i', $result['ErrMsg'],$match);
$this-&webtoken = $match[1];
$this-&setToken($this-&webtoken);
$this-&setCookies($this-&_curlHttpObject-&getCookies());
return $result['ErrCode'];
* @name 执行关联动作
private function doAssociationAction()
//var_dump($this-&_passiveAssociationSwitch && Wechat::MSGTYPE_EVENT!=$this-&getRevType() && is_object($this-&_wechatcallbackFuns) && method_exists($this-&_wechatcallbackFuns, &getAscStatusByOpenid&) && method_exists($this-&_wechatcallbackFuns, &setAssociation&) && !$this-&_wechatcallbackFuns-&getAscStatusByOpenid($this-&getRevFrom()));
if ($this-&_passiveAssociationSwitch && Wechat::MSGTYPE_EVENT!=$this-&getRevType() && is_object($this-&_wechatcallbackFuns) && method_exists($this-&_wechatcallbackFuns, &getAscStatusByOpenid&) && method_exists($this-&_wechatcallbackFuns, &setAssociation&) && !$this-&_wechatcallbackFuns-&getAscStatusByOpenid($this-&getRevFrom()))
//$messageList = $this-&getMessage();
$messageList = $this-&getMessageAjax(0, 40, 0, +intval(mt_rand(0, 99999)));
if ($messageList)
$count = 0;
$fakeid = &&;
foreach ($messageList as $value)
if ($value[&dateTime&]==$this-&getRevCtime())
$count += 1;
$fakeid = $value[&fakeId&];
if (1==$count && $fakeid!=&&)
$detailInfo = NULL;
if ($this-&_passiveAscGetDetailSwitch)
$detailInfo = $this-&getContactInfo($fakeid);
$this-&_wechatcallbackFuns-&setAssociation((string)$this-&getRevFrom(), $fakeid, $detailInfo);
* 验证登录是否在线
* @return boolean
public function checkValid()
$postfields = array();
$url = $this-&protocol.&://mp./cgi-bin/getregions?id=1054&t=ajax-getregions&lang=zh_CN&token=&.$this-&
//判断cookie是否为空,为空的话自动执行登录
if ($this-&_cookies||$this-&_cookies = $this-&getCookies())
$this-&curlInit(&single&);
$response = $this-&_curlHttpObject-&get($url, $this-&protocol.&://mp./cgi-bin/&, $this-&_cookies);
$result = json_decode($response,1);
if(isset($result['num']))
* keepLive心跳包保持,在线状态,推荐通过cron每15分钟调用一下
* @return boolean
public function keepLive()
if (!$this-&checkValid()) {
return (true===$this-&login());
* 主动单条发消息
string $id
用户的fakeid
string $content 发送的内容
* @return integer 返回发送结果:成功返回:1,登录问题返回:-1,其他原因返回:0
public function send($fakeid,$content)
//判断cookie是否为空,为空的话自动执行登录
if (file_exists($this-&cookiefilepath)||true===$this-&login())
$postfields = array();
$postfields['tofakeid'] = $
$postfields['type'] = 1;
$postfields['error']= &false&;
$postfields['token']= $this-&
$postfields['content'] = $
$postfields['ajax'] = 1;
$url = $this-&protocol.&://mp./cgi-bin/singlesend?t=ajax-response&;
$this-&curlInit(&single&);
$response = $this-&_curlHttpObject-&post($url, $postfields, $this-&protocol.&://mp./&, $this-&_cookies);
$tmp = json_decode($response,true);
//判断发送结果的逻辑部分
if ('ok'==$tmp[&msg&]) {
elseif ($tmp['ret']==&-2000&)
return -1;
//登录失败返回false
* 主动群发相同消息,目前暂支持文本方式
array $fakeidGroup
接受微信fakeid集合数组
string $content 群发消息内容
* @return mixed
返回一个记录发送结果的数组列表
* 这里需要注意请求耗时问题,目前采用curl并发性请求.
public function batSend($fakeidGroup,$content)
$queueSendArray = array();
foreach ($fakeidGroup as $key =&$value)
$queueSendArray[] = array(
'fakeid' =& $value,
'content' =& $content
return $this-&doQueueSend($queueSendArray);
* 主动发送队列消息,目前暂支持文本方式
* @param array 发送队列数组
array(array('fakeid'='','content'))
* @param integer $queueCount 并发数量,默认10
* @return mixed
返回一个记录发送结果的数组列表
* 这里需要注意请求耗时问题,目前采用curl并发性请求.
public function queueSend($queueSendArray,$queueCount=10)
return $this-&doQueueSend($queueSendArray,$queueCount);
* 执行主动发送队列,默认并发队列数是10
* @param array $queueSendArray 发送队列数组
array(array('fakeid'='','content'))
* @param integer $queueCount 并发数量,默认10
* @return array
返回一个记录发送结果的数组列表
private function doQueueSend($queueSendArray, $queueCount=10)
$requestArray = array();
foreach ($queueSendArray as $key =&$value)
$postfields = array();
$postfields['tofakeid'] = $value['fakeid'];
$postfields['type'] = 1;
$postfields['error']= &false&;
$postfields['token']= $this-&
$postfields['content'] = $value['content'];
$postfields['ajax'] = 1;
$url = $this-&protocol.&://mp./cgi-bin/singlesend?t=ajax-response&;
$requestArray[] = array('url'=&$url,'method'=&'post','postfields'=&$postfields,'referer'=&$this-&protocol.&://mp./&,'cookies'=&$this-&_cookies);
function callback($result, $key){
$tmp = json_decode($result,true);
//判断发送结果的逻辑部分
if ('ok'==$tmp[&msg&]) {
elseif ($tmp['ret']==&-2000&)
return -1;
$this-&curlInit(&roll&);
$this-&_curlHttpObject-&setRollLimitCount($queueCount);
$response = $this-&_curlHttpObject-&setCallback(&callback&)-&rollRequest($requestArray);
* 获取用户的信息
string $fakeid 用户的fakeid
* @return mixed 如果成功获取返回数据数组,登录问题返回false,其他未知问题返回true,
public function getContactInfo($fakeid)
$url = $this-&protocol.&://mp./cgi-bin/getcontactinfo?t=ajax-getcontactinfo&lang=zh_CN&fakeid=&.$
$this-&curlInit(&single&);
$postfields = array(&token&=&$this-&webtoken, &ajax&=&1);
$response = $this-&_curlHttpObject-&post($url, $postfields, $this-&protocol.&://mp./&, $this-&_cookies);
$result = json_decode($response,1);
if($result['FakeId']){
elseif ($result['ret'])
* 获取消息所附文件
string $msgid 消息的id
* @return array 如果成功获取返回下载的文件的基本信息
public function getDownloadFile($msgid, $filepath = null)
if ($this-&_cookies||true===$this-&login())
$url = $this-&protocol.&://mp./cgi-bin/downloadfile?token=&.$this-&webtoken.&&msgid=$msgid&source=&;
$ch = curl_init();
$tmpfile = $filepath?$filepath:tempnam(sys_get_temp_dir(), 'WechatFileTemp');
$fp = @fopen($tmpfile,&w&);
if ($fp) {
curl_setopt($ch, CURLOPT_URL, $url);
$options = array(
CURLOPT_RETURNTRANSFER =& true,
// return web page
CURLOPT_HEADER
CURLOPT_FOLLOWLOCATION =& true,
// follow redirects
CURLOPT_ENCODING
// handle all encodings
CURLOPT_USERAGENT
// who am i
CURLOPT_AUTOREFERER
// set referer on redirect
CURLOPT_CONNECTTIMEOUT =& 10,
// timeout on connect
CURLOPT_TIMEOUT
// timeout on response
CURLOPT_MAXREDIRS
// stop after 10 redirects
CURLOPT_POST
// i am sending post data
CURLOPT_SSL_VERIFYHOST =& 0,
// don't verify ssl
CURLOPT_SSL_VERIFYPEER =& false,
CURLOPT_FILE =& $fp, //目标文件保存路径
CURLOPT_RETURNTRANSFER =& 1
curl_setopt_array($ch, $options);
$reqCookiesString = &&;
if(is_array($this-&_cookies)){
foreach ($this-&_cookies as $key =& $val){
$reqCookiesString .=
$key.&=&.$val.&; &;
curl_setopt($ch, CURLOPT_COOKIE, $reqCookiesString);
$content = curl_exec($ch);
$info = (curl_getinfo($ch));
curl_close($ch);
fwrite($fp, $content);
fclose($fp);
$result = array();
echo filesize($tmpfile);
if ($content && file_exists($tmpfile) && filesize($tmpfile)&0 && $info[&content_type&]!=&text/html&) {
echo &XXX&;
$result[&filename&] = $
$result[&filesize&] = filesize($tmpfile);
$result['filetype'] = $info[&content_type&];
* @name 获取公共消息列表(html)
* @param number $day
* @param number $count 数量限制
* @param number $page 页数
* @return array|boolean
public function getMessage($day=0, $count=100, $page=1)
if ($this-&_cookies||true===$this-&login())
$url = $this-&protocol.&://mp./cgi-bin/getmessage?t=wxm-message&token=&.$this-&webtoken.&&lang=zh_CN&count=100&;
$this-&curlInit(&single&);
$result = $this-&_curlHttpObject-&get($url, $this-&protocol.&://mp./cgi-bin/&, $this-&_cookies);
if (preg_match('%&script type=&json& id=&json-msgList&&([\s\S]*?)&/script&%', $result, $match)) {
$tmp = json_decode($match[1], true);
* @name 获取与指定用户的对话信息列表
* @param string $fakeid 要获取指定用户消息的fakeid(必选)
* @param number $lastmsgid 最早消息的id
* @param number $createtime 最早消息的时间戳
* @param string $lastmsgfromfakeid 消息最后来源
public function getSingleMessage($fakeid, $lastmsgid=1, $createtime=0, $lastmsgfromfakeid=null)
if (!empty($this-&_cookies))
$url = $this-&protocol.&://mp./cgi-bin/singlemsgpage?t=ajax-single-getnewmsg&;
$this-&curlInit(&single&);
$postfield = array();
$postfield['createtime']=$
$postfield['fromfakeid']=$
$postfield['opcode']=1;
$postfield['lastmsgfromfakeid']=$
$postfield['lastmsgid']=$
$postfield['token']=$this-&
$postfield['ajax']=1;
$result = $this-&_curlHttpObject-&post($url, $postfield, $this-&protocol.&://mp./&,$this-&_cookies);
if ($result)
return json_decode($result, true);
* @name 获取公共消息时间线列表
* @param number $day 获取几日内的消息参数(0:当天;1:昨天;2:前天;3:最近5天.默认0)
* @param number $count 获取消息数量限制.默认100
* @param number $offset 获取消息开始位置,差不多是偏移分页的样子.默认是0
* @param number $msgid 最后消息的id 默认为(意味着全部消息的意思)
* @param boolean $timeline 这个参数决定了上面的$day是否有效,设置成false,直接按时间线排列的全部消息
* @return mixed|boolean
public function getMessageAjax($day=0, $count=100, $offset=1, $msgid=, $timeline=1)
if ($this-&_cookies||true===$this-&login())
$url = $this-&protocol.&://mp./cgi-bin/getmessage?t=ajax-message&lang=zh_CN&count=$count&timeline=&.($timeline?&1&:&&).&&day=$day&star=&frommsgid=$msgid&cgi=getmessage&offset=&.intval($offset);
$this-&curlInit(&single&);
$postfieldArray = array(
&token& =& $this-&webtoken,
&ajax& =& 1
$header = array(
&X-Requested-With& =& &XMLHttpRequest&
$result = $this-&_curlHttpObject-&post($url, $postfieldArray, $this-&protocol.&://mp./cgi-bin/&, $this-&_cookies, $header);
if ($result) {
return json_decode($result, true);
* @name 得到确定的某条消息(因为微信两个时间戳有时不同, 所以这个接口效果不完美)
* @param string $datetime
public function getOneMessage($datetime=NULL, $type=NULL, $openid=NULL)
if (!$type) {
$type = $this-&getRevType();
if (!$datetime) {
$datetime = $this-&getRevCtime();
if (!$openid) {
$openid = $this-&getRevFrom();
file_put_contents(&log.txt&, &\n[b]&.$this-&getRevCtime().&[/b]*****\n&,FILE_APPEND);
$typeList = array(Wechat::MSGTYPE_TEXT=&1, Wechat::MSGTYPE_IMAGE=&2, Wechat::MSGTYPE_VOICE=&3, Wechat::MSGTYPE_VIDEO=&4, Wechat::MSGTYPE_LOCATION=&1);
if ($openid && method_exists($this-&_wechatcallbackFuns, &getAscStatusByOpenid&) && is_array($userInfo = $this-&_wechatcallbackFuns-&getAscStatusByOpenid($openid)))
file_put_contents(&log.txt&, &A\n&.serialize($userInfo),FILE_APPEND);
if ($userInfo['fakeid'])
file_put_contents(&log.txt&, &B\n&,FILE_APPEND);
$singleMessage = $this-&getSingleMessage($userInfo['fakeid'], 1, (string)(intval($datetime)-10));
$singleMessageCount = count($singleMessage);
file_put_contents(&log.txt&, (string)(intval($datetime)-0).&\n&,FILE_APPEND);
if ($singleMessageCount==1)
file_put_contents(&log.txt&, &\$singleMessageCount:$singleMessageCount\n&,FILE_APPEND);
if( $userInfo['fakeid']==$singleMessage[0]['fakeId'] && (empty($type) || $singleMessage[0]['type']==$typeList[$type]) )
file_put_contents(&log.txt&, serialize($singleMessage[0]).&\n&,FILE_APPEND);
return $singleMessage[0];
elseif ($singleMessageCount&1)//TODO 当前进度在这
for($i=0;$i&$singleMessageC$i++)
if ( $userInfo['fakeid']==$singleMessage[0]['fakeId'] && $datetime == $singleMessage[$i]['dateTime'])
file_put_contents(&log.txt&, serialize($singleMessage[$i]).&\n&,FILE_APPEND);
return $singleMessage[$i];
file_put_contents(&log.txt&, $singleMessageCount.&\n&,FILE_APPEND);
for($i=0;$i&$singleMessageC$i++)
if( $userInfo['fakeid']==$singleMessage[$i]['fakeId'] && $singleMessage[$i]['type']==$typeList[$type])
file_put_contents(&log.txt&, serialize($singleMessage[$i]).&\n&,FILE_APPEND);
return $singleMessage[$i];
file_put_contents(&log.txt&, &False\n&,FILE_APPEND);
return FALSE;
//获取40条最新的公共消息列表
$messageList = $this-&getMessageAjax(0, 40, 0, +intval(mt_rand(0, 99999)));
$messageListCount = count($messageList);
if ($messageListCount&0) {
$matchMessageList = array();
for($i=0;$i&$messageListC$i++)
if (($datetime?$datetime:$this-&getRevCtime()) == $messageList[$i]['dateTime'] && ($type?($messageList[$i]['type']==$typeList[$type]):true))
$matchMessageList[] = $messageList[$i];
if (count($matchMessageList)==1) {
return $matchMessageList[0];
return FALSE;
* @name 得到指定分组的用户列表
* @param number $groupid
* @return Ambigous &boolean, string, mixed&
public function getfriendlist($groupid=0, $pagesize=100)
$url = $this-&protocol.&://mp./cgi-bin/contactmanagepage?token=$this-&webtoken&t=wxm-friend&pagesize=$pagesize&groupid=$groupid&;
$referer = $this-&protocol.&://mp./&;
$this-&curlInit(&single&);
$response = $this-&_curlHttpObject-&get($url, $referer, $this-&_cookies);
$tmp = &&;
if (preg_match('%&script id=&json-friendList& type=&json/text&&([\s\S]*?)&/script&%', $response, $match)) {
$tmp = json_decode($match[1], true);
return empty($tmp)?false:$
* 获取用户的fakeid
* @param callback $callback 处理匹配结果的回调函数,剥离出来方便大家自己的实现自己的逻辑,大致就是循环的查找,并写入数据库之类的
* 下面是示例:
function callback($result, $key, $request, $otherCallbackArg){
$reruen_tmp =
dump($result);
foreach ($otherCallbackArg['data'] as $data_key =& $data_value)
if(false !== strpos($result, substr(md5($data_value['openid']), 0, 16)))
$subscribeusersModel = D(&Subscribeusers&);
$condition['openid'] = $data_value['openid'];
$data = $subscribeusersModel-&where($condition)-&save(array('fakeid'=&$request['postfields']['fromfakeid']));
$otherCallbackArg['wechatObj']-&putIntoGroup($request['postfields']['fromfakeid'], 101);
$reruen_tmp = $data_value['openid'];
return $reruen_
print_r($this-&wechatObj-&getfakeid(&callback&));
/* public function getfakeid($callback)
//接下来是数据库的访问,大家可以按照自己的环境修改,接下来会通过回调函数解决。
$subscribeusersModel = D(&Subscribeusers&);
$data = $subscribeusersModel-&where(' `fakeid` IS NULL and `unsubscribed`=0')-&select();
//$data 是当前fakeid为空的用户的列表数组
if (!is_array($data))
die(&none data&);
$unfriendList = $this-&getfriendlist(0);
if (!$unfriendList){
die(&none friendlist&);
$requestArray = array();
foreach ($unfriendList as $key =& $value)
$requestArray[$key]['postfields']['createtime'] = time()-60000;
$requestArray[$key]['postfields']['fromfakeid'] = $value['fakeId'];
$requestArray[$key]['postfields']['opcode'] = 1;
$requestArray[$key]['postfields']['token'] = $this-&
$requestArray[$key]['postfields']['ajax'] = 1;
$requestArray[$key]['referer'] = $this-&protocol.&://mp./&;
$requestArray[$key]['cookiefilepath'] = $this-&
$requestArray[$key]['method'] = &post&;
$requestArray[$key]['url'] = $this-&protocol.&://mp./cgi-bin/singlemsgpage?t=ajax-single-getnewmsg&;
$this-&curlInit(&roll&);
$rollingCurlObj-&setOtherCallbackArg(array('data'=&$data, 'wechatObj'=&$this));
$response = $rollingCurlObj-&setCallback($callback)-&request($requestArray);
dump($response);
* 将用户放入制定的分组
* @param array $fakeidsList
* @param string $groupid
* @return boolean 放入是否成功
public function putIntoGroup($fakeidsList, $groupid)
$fakeidsListString = &&;
if(is_array($fakeidsList))
foreach ($fakeidsList as $value)
$fakeidsListString .= $value.&|&;
$fakeidsListString = $fakeidsL
$postfields['contacttype'] = $
$postfields['tofakeidlist'] = $fakeidsListS
$postfields['token'] = $this-&
$postfields['ajax'] = 1;
$referer = $this-&protocol.&://mp./&;
$url = $this-&protocol.&://mp./cgi-bin/modifycontacts?action=modifycontacts&t=ajax-putinto-group&;
$this-&curlInit(&roll&);
$response = $this-&_wechatcallbackFuns-&post($url, $postfields, $referer, $this-&_cookies);
$tmp = json_decode($response, true);
$result = $tmp['ret']==&0&&&!empty($tmp)?true:
public function setWechatToolFun($class){
if (is_string($class)) {
$toolObj = new $
if (is_object($toolObj)) {
$this-&_wechatcallbackFuns = $toolO
elseif (is_object($class)){
$this-&_wechatcallbackFuns = $
* @return the $wechatOptions
public function getCookies() {
return $this-&_wechatcallbackFuns-&getCookies();
* @return the $wechatOptions
public function getToken() {
return $this-&_wechatcallbackFuns-&getToken();
* @return the $wechatOptions
public function getWechatOptions() {
return $this-&wechatO
* 设置微信配置信息
* @param multitype:string
$wechatOptions
public function setWechatOptions($wechatOptions) {
$this-&wechatOptions = array_merge($this-&wechatOptions, $wechatOptions);
* 设置cookie保存位置
* @param string $cookies cookie
public function setCookies($cookies) {
$this-&_wechatcallbackFuns-&setCookies($cookies);
* 设置token保存
* @param string $token token
public function setToken($token) {
$this-&_wechatcallbackFuns-&setToken($token);
* @param boolean $debug
public function setDebug($debug) {
$this-&debug = $
* 设置是否自动附带发送openid开关,default:False
* @param boolean $autosendopenid
* @return Wechat
public function setAutoSendOpenidSwitch($autosendopenid=FALSE) {
$this-&_autosendopenid = $
* @设置被动关联动作开关
* @param boolean $switch 开关
* @param boolean $detailSwitch 是否获取用户详细信息开关
* @return Wechat
public function setPassiveAscSwitch($switch, $detailSwitch=false) {
$this-&_passiveAssociationSwitch = $
$this-&_passiveAscGetDetailSwitch = $detailS
* Rolling Curl Request Class
* @author Ligboy ()
* @copyright
* @example
class CurlHttp {
/ 单线程请求设置项 /
/ 并发请求设置项 /
private $limitCount = 10; //并发请求数量
public $returninfoswitch =
//是否返回请求信息,开启后单项请求返回结果为:array('info'=&请求信息, 'result'=&返回内容, 'error'=&错误信息)
//私有属性
private $singlequeue =
private $rollqueue =
private $_requstItems =
private $_callback =
private $_
private $_referer =
private $_cookies = array();
private $_
private $_reqheader = array();
private $_
private $_redirect_
private $_singleoptions = array(
CURLOPT_RETURNTRANSFER =& true,
// return web page
CURLOPT_HEADER
// don't return headers
CURLOPT_FOLLOWLOCATION =& true,
// follow redirects
CURLOPT_NOSIGNAL
CURLOPT_ENCODING
// handle all encodings
CURLOPT_USERAGENT
// who am i
CURLOPT_AUTOREFERER
// set referer on redirect
CURLOPT_CONNECTTIMEOUT =& 120,
// timeout on connect
CURLOPT_TIMEOUT
// timeout on response
CURLOPT_MAXREDIRS
// stop after 10 redirects
CURLOPT_SSL_VERIFYHOST =& 0,
// don't verify ssl
CURLOPT_SSL_VERIFYPEER =& false,
private $_rolloptions = array(
CURLOPT_RETURNTRANSFER =& true,
// return web page
CURLOPT_HEADER
// don't return headers
CURLOPT_FOLLOWLOCATION =& true,
// follow redirects
CURLOPT_NOSIGNAL
CURLOPT_ENCODING
// handle all encodings
CURLOPT_USERAGENT
// who am i
CURLOPT_AUTOREFERER
// set referer on redirect
CURLOPT_CONNECTTIMEOUT =& 120,
// timeout on connect
CURLOPT_TIMEOUT
// timeout on response
CURLOPT_MAXREDIRS
// stop after 10 redirects
CURLOPT_SSL_VERIFYHOST =& 0,
// don't verify ssl
CURLOPT_SSL_VERIFYPEER =& false,
function singleInit($options = array()) {
if (!$this-&singlequeue) {
$this-&singlequeue = curl_init();
if ($options) {
$this-&_singleoptions = array_merge($this-&_singleoptions, $options);
function rollInit($options = array()) {
if(!$this-&rollqueue){
$this-&rollqueue = curl_multi_init();
if ($options) {
$this-&_rolloptions = array_merge($this-&_rolloptions, $options);
* @name 返回Header数组
* @param resource $ch
* @return string
private function getResRawHeader($ch, $result) {
$ch_info = curl_getinfo($ch);
$header_size = $ch_info[&header_size&];
$rawheader = substr($result, 0, $ch_info['header_size']);
* @name 返回Header数组
* @param resource $ch
* @return string
private function getResHeader($ch, $result) {
$header = array();
$rawheader = $this-&getResRawHeader($ch, $result);
if(preg_match_all('/([^:\s]+): (.*)/i', $rawheader, $header_match)){
for($i=0;$i&count($header_match[0]);$i++){
$header[$header_match[1][$i]] = $header_match[2][$i];
* @name 返回网页主体内容
* @param resource $ch
* @return string 网页主体内容
private function getResBody($ch, $result) {
$ch_info = curl_getinfo($ch);
$body = substr($result, -$ch_info['download_content_length']);
* @name 返回网页主体内容
* @param resource $ch
* @return array 网页主体内容
private function getResCookies($ch, $result) {
$rawheader = $this-&getResRawHeader($ch, $result);
$cookies = array();
if(preg_match_all('/Set-Cookie:(?:\s)([^=]?)=([^\;]*?);/i', $rawheader, $cookie_match)){
for($i=0;$i&count($cookie_match[0]);$i++){
$cookies[$cookie_match[1][$i]] = $cookie_match[2][$i];
private function setReqCookies($ch, $reqcookies = array()) {
$reqCookiesString = &&;
if(!empty($reqcookies)){
if(is_array($reqcookies)){
foreach ($reqcookies as $key =& $val){
$reqCookiesString .=
$key.&=&.$val.&; &;
curl_setopt($ch, CURLOPT_COOKIE, $reqCookiesString);
}elseif(!empty($this-&_cookies)) {
foreach ($this-&_cookies as $key =& $val){
$reqCookiesString .=
$key.&=&.$val.&; &;
curl_setopt($ch, CURLOPT_COOKIE, $reqCookiesString);
private function setResCookies($ch) {
if(!empty($reqcookies)&&is_array($reqcookies)){
$this-&_cookies = array_merge($this-&_cookies, $reqcookies);
* @param unknown $url
* @param mixed $postfields
* @param string $referer
* @param array $reqcookies
* @return unknown
function post($url, $postfields=null, $referer=null, $reqcookies=null, $reqheader=array())
$this-&singlequeue = curl_init($url);
$options = array(
CURLOPT_RETURNTRANSFER =& true,
// return web page
CURLOPT_HEADER
// don't return headers
CURLOPT_FOLLOWLOCATION =& true,
// follow redirects
CURLOPT_ENCODING
// handle all encodings
CURLOPT_USERAGENT
// who am i
CURLOPT_AUTOREFERER
// set referer on redirect
CURLOPT_CONNECTTIMEOUT =& 120,
// timeout on connect
CURLOPT_TIMEOUT
// timeout on response
CURLOPT_MAXREDIRS
// stop after 10 redirects
CURLOPT_POST
// i am sending post data
CURLOPT_POSTFIELDS
=& $postfields,
// this are my post vars
CURLOPT_SSL_VERIFYHOST =& 0,
// don't verify ssl
CURLOPT_SSL_VERIFYPEER =& false,
curl_setopt_array($this-&singlequeue, $options);
if($referer){
curl_setopt($this-&singlequeue, CURLOPT_REFERER, $referer);
elseif ($this-&referer){
curl_setopt($this-&singlequeue, CURLOPT_REFERER, $this-&referer);
$this-&setReqheader($this-&singlequeue, $reqheader);
$this-&setReqCookies($this-&singlequeue, $reqcookies);
$result = curl_exec($this-&singlequeue);
$resCookies = $this-&getResCookies($this-&singlequeue, $result);;
if (is_array($resCookies)&&!empty($resCookies)) {
$this-&_cookies = array_merge($this-&_cookies ,$resCookies);
$resHeader = $this-&getResHeader($this-&singlequeue, $result);
if (is_array($resHeader)&&!empty($resHeader)) {
$this-&_resheader = $resH
$this-&_result = $this-&getResBody($this-&singlequeue, $result);
curl_close($this-&singlequeue);
$this-&singlequeue =
return $this-&_
* @param unknown $url
* @param unknown $postfields
* @param unknown $referer
* @return unknown
function get($url, $referer=null, $reqcookies=null, $reqheader=array())
$this-&singlequeue = curl_init($url);
$options = array(
CURLOPT_RETURNTRANSFER =& true,
// return web page
CURLOPT_HEADER
// don't return headers
CURLOPT_FOLLOWLOCATION =& true,
// follow redirects
CURLOPT_ENCODING
// handle all encodings
CURLOPT_USERAGENT
// who am i
CURLOPT_AUTOREFERER
// set referer on redirect
CURLOPT_CONNECTTIMEOUT =& 120,
// timeout on connect
CURLOPT_TIMEOUT
// timeout on response
CURLOPT_MAXREDIRS
// stop after 10 redirects
CURLOPT_POST
// i am sending post data
CURLOPT_SSL_VERIFYHOST =& 0,
// don't verify ssl
CURLOPT_SSL_VERIFYPEER =& false,
CURLOPT_REFERER
=&$referer,
curl_setopt_array($this-&singlequeue, $options);
if($referer){
curl_setopt($this-&singlequeue, CURLOPT_REFERER, $referer);
elseif ($this-&referer){
curl_setopt($this-&singlequeue, CURLOPT_REFERER, $this-&referer);
$this-&setReqheader($this-&singlequeue, $reqheader);
$this-&setReqCookies($this-&singlequeue, $reqcookies);
$result = curl_exec($this-&singlequeue);
$resCookies = $this-&getResCookies($this-&singlequeue, $result);
if (is_array($resCookies)&&!empty($resCookies)) {
$this-&_cookies = array_merge($this-&_cookies ,$resCookies);
$resHeader = $this-&getResHeader($this-&singlequeue, $result);
if (is_array($resHeader)) {
$this-&_resheader = $resH
$this-&_result = $this-&getResBody($this-&singlequeue, $result);
curl_close($this-&singlequeue);
$this-&singlequeue =
return $this-&_
* 并发行的curl方法
* @param unknown $requestArray
* @param string $callback
* @return multitype:multitype:
function rollRequest($requestArray, $callback=&&)
$this-&_requstItems = $requestA
$requestArrayKeys = array_keys($requestArray);
$requestArray = array(
'url' =& &&,
'method' =& &post&,
'postfields' =& array(),
'cookies' =& &&,
'referer' =& &&,
'url' =& &&,
'postfields' =& array(),
'cookies' =& &&,
'referer' =& &&,
$this-&rollqueue = curl_multi_init();
$map = array();
for ($i=0;$i&$this-&limitCount && !empty($requestArrayKeys);$i++)
$keyvalue = array_shift($requestArrayKeys);
$this-&addToRollQueue( $requestArray, $keyvalue, $map );
$responses = array();
while (($code = curl_multi_exec($this-&rollqueue, $active)) == CURLM_CALL_MULTI_PERFORM) ;
if ($code != CURLM_OK) { }
// 找到刚刚完成的任务句柄
while ($done = curl_multi_info_read($this-&rollqueue)) {
// 处理当前句柄的信息、错误、和返回内容
$info = curl_getinfo($done['handle']);
$error = curl_error($done['handle']);
if ($this-&_callback)
//调用callback函数处理当前句柄的返回内容,callback函数参数有:(返回内容, 队列id)
$result = call_user_func($this-&_callback, curl_multi_getcontent($done['handle']), $map[(string) $done['handle']]);
//如果callback为空,直接返回内容
$result = curl_multi_getcontent($done['handle']);
if ($this-&returninfoswitch) {
$responses[$map[(string) $done['handle']]] = compact('info', 'error', 'result');
$responses[$map[(string) $done['handle']]] = $
// 从队列里移除上面完成处理的句柄
curl_multi_remove_handle($this-&rollqueue, $done['handle']);
curl_close($done['handle']);
if (!empty($requestArrayKeys))
$addkey = array_shift($requestArrayKeys);
$this-&addToRollQueue ( $requestArray, $addkey, $map );
// Block for data in / error handling is done by curl_multi_exec
if ($active & 0) {
curl_multi_select($this-&rollqueue, 0.5);
} while ($active);
curl_multi_close($this-&rollqueue);
$this-&rollqueue =
* @param requestArray
* @param map
* @param keyvalue
private function addToRollQueue($requestArray, $keyvalue, &$map) {
$ch = curl_init();
curl_setopt_array($ch, $this-&_rolloptions);
//检查提交方式,并设置对应的设置,为空的话默认采用get方式
if (&post& === $requestArray[$keyvalue]['method'])
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $requestArray[$keyvalue]['postfields']);
curl_setopt($ch, CURLOPT_HTTPGET, true);
if($requestArray[$keyvalue]['referer']){
curl_setopt($ch, CURLOPT_REFERER, $requestArray[$keyvalue]['referer']);
elseif ($this-&referer){
curl_setopt($ch, CURLOPT_REFERER, $this-&referer);
$this-&setReqheader($ch, $requestArray[$keyvalue]['header']);
//cookies设置
$this-&setReqCookies($ch, $requestArray[$keyvalue]['cookies']);
curl_setopt($ch, CURLOPT_URL, $requestArray[$keyvalue]['url']);
curl_setopt($ch, CURLOPT_REFERER, $requestArray[$keyvalue]['referer']);
curl_multi_add_handle($this-&rollqueue, $ch);
$map[(string) $ch] = $
* 返回当前并行数
* @return the $limitCount
public function getRollLimitCount() {
return $this-&limitC
* 设置并发性请求数量
* @param number $limitCount
public function setRollLimitCount($limitCount) {
$this-&limitCount = $limitC
* 设置回调函数
* @param field_type $_callback
public function setCallback($_callback) {
$this-&_callback = $_
public function getResult() {
return $this-&_
public function getRawHeader() {
return $this-&_
public function getCookies() {
return $this-&_
public function setCookies($_cookies) {
$this-&_cookies = $_
* @param unknown_type $reqheader
public function setHeader($header) {
$this-&_reqheader = array_merge($this-&_reqheader, $header);
* @param unknown_type $reqheader
private function setReqheader($ch, $reqheader) {
$reqheader = array_merge($this-&_reqheader, $reqheader);
if (is_array($reqheader)) {
$rawReqHeader = array();
foreach ($reqheader as $key =& $value){
$rawReqHeader[] = &$key: $value&;
curl_setopt($ch, CURLOPT_HTTPHEADER, $rawReqHeader);
$this-&_reqheader = array();
该问题目前已经被锁定, 无法添加新回复
么么吻育儿网-&
浏览: 12095
关注: 1 人

我要回帖

更多关于 狗带是什么意思 的文章

 

随机推荐