dodgepudding / wechat-php-sdk Goto Github PK
View Code? Open in Web Editor NEW微信公众平台php开发包, weixin developer SDK.
微信公众平台php开发包, weixin developer SDK.
sendNews($account,$title,$summary,$content,$pic,$srcurl='') 向一个微信账户发送图文信息
此方法在哪里?
测试你的test.php时,出现如下的信息:
array(2) { ["ret"]=> string(6) "-20000" ["msg"]=> string(19) "Request is denied! " }
问一下,uid是如何获取的?
不明原因 出现了-2
public function login($log=false){
$snoopy = new Snoopy;
$send_snoopy->referer ="https://mp.weixin.qq.com/";
$submit = "https://mp.weixin.qq.com/cgi-bin/login?lang=zh_CN";
$post["username"] = $this->_account;
$post["pwd"] = md5($this->_password);
$post["imgcode"] = "";
echo json_encode($post);
$post["f"] = "json";
$snoopy->submit($submit,$post);
if($log){
echo "--".$snoopy->results."--";
}
$cookie = '';
$this->log($snoopy->headers);
foreach ($snoopy->headers as $key => $value) {
$value = trim($value);
if(preg_match('/^set-cookie:[\s]+([^=]+)=([^;]+)/i', $value,$match))
$cookie .=$match[1].'='.$match[2].'; ';
}
if ($cookie) {
$send_snoopy = new Snoopy;
$send_snoopy->rawheaders['Cookie']= $cookie;
$send_snoopy->maxredirs = 0;
$url = "https://mp.weixin.qq.com/cgi-bin/indexpage?t=wxm-index&lang=zh_CN";
$send_snoopy->fetch($url);
$header = implode(',',$send_snoopy->headers);
$this->log('header:'.print_r($send_snoopy->headers,true));
preg_match("/token=(\d+)/i",$header,$matches);
if($matches){
$this->_token = $matches[1];
$this->log('token:'.$this->_token);
}
}
//获取toUserId OpenID
$cookieArray = explode(";",$cookie);
for($i=0;$i<count($cookieArray);$i++){
$tmp=explode("=",$cookieArray[$i]);
if(trim($tmp[0])=="slave_user"){
$this->w_id=$tmp[1];
}
}
$this->saveCookie($this->_cookiename,$cookie);
return $cookie;
}
结果如下:
{
"Ret": 400,
"ErrMsg": "",
"ShowVerifyCode": 0,
"ErrCode": -2
}
目前路径已经失效。
http://mp.weixin.qq.com/cgi-bin/indexpage?t=wxm-index&lang=zh_CN 获得的是404
$send_snoopy->submit($submit,$post); // 此处$post没定义
uploadFile 方法上传图片失败,好像微信公众平台修改了上传图片的方式
Array
(
[0] => HTTP/1.1 200 OK
[1] => Server: nginx/0.7.64
[2] => Date: Sun, 23 Jun 2013 03:14:43 GMT
[3] => Content-Type: application/json; charset=UTF-8
[4] => Connection: keep-alive
[5] => Content-Length: 65
[6] => Cache-Control: no-cache, must-revalidate
)
{"ret":"-20000", "msg":"Request is denied! "}
请问有同学遇到这个问题吗,初了在微信官方后端可以使用编辑器,自己开发可以吗?
微信借口更新了,期待你的更新啊!哈哈……
这几天使用uploadFile方法上传图片失败,之前一直都能用。下面是腾讯服务器返回的信息:
<script>
document.domain = location.hostname.match(/[^\.]*?\.[^\.]*?$/);
var
url = window.location.href,
type = url.match(/[\?&]type=([^&]*)/),
formId = url.match(/[\?&]formId=([^&]*)/);
type = type[1] || 0;
formId = formId[1];
top.W.upload.err("上传文件失败", type, formId);
</script>
public function getRevFrom() {
if ($this->_receive)
return $this->_receive['FromUserName'];
...
public function getRevTo() {
if ($this->_receive)
return $this->_receive['ToUserName'];
....
public function getRevType() {
if (isset($this->_receive['MsgType']))
return $this->_receive['MsgType'];
这里判断条件不一样是有特别原因?如果没有,建议用$this->_receive[] 这样风格比较统一。
Hello, I am new here. Can anyone please guide me how to use this API. I saw the comments but they are mostly written in Korean (or Japanese? or Chinese?) I don't speak or read any of them. Please give me an instruction. Also I saw some 'tokenaccesskey' is required. How to get that?
Thanks in advance
都是很小的问题,但debug花了不少时间
你的README中test1.php的第一行include少了一个分号
另外wechat.class.php第317行应该是:xml =
主动发送,遇到"ret":"-20000", "msg":"Request is denied! "
请问怎么处理
$submit = "https://mp.weixin.qq.com/cgi-bin/message?t=message/list&lang=zh_CN{$addstar}&count=$perpage&timeline=$today&day=$day&frommsgid=$lastid&offset=$offset";
this link will show a login session expired page.
After I append the token to the link, the problem seems solved.
你好,我的问题如题所示,系统返回的多条信息包括多条文字,跟音频回复
wechatext.class.php中,addPreview函数
if ($srcurl[$i]) $post['srcurl'.$i] = $srcurl[$i];
应该为
if ($srcurl[$i]) $post['sourceurl'.$i] = $srcurl[$i];
为什么Wechatext中upload()方法不能上传语言/视频文件,但是能上传图片?自己尝试过很多次,但是都是如此,检查过代码,看不出什么原因,但是上传mp3的时候,就会出现NetworkError: 500 Internal Server Error错误,这个错误应该是指代码错误,但是上传图片却可以,不明白啊不明白,能指教下吗?
发送客服消息接口,940行因加了return false 导致发送失败不返回信息
原先随便输入一些内容即可,现在必须输入正确才行了。HELP
如题
比如发送一条信息过去,为 ‘hi’ ,应该返回一次 ‘你好’
但是,后台会反馈多次‘你好’。
用回官方的API就正常。
不知道各位有遇到这个问题么?
想获取用户管理页面的用户列表,使用Snoopy 中的fetch返回的页面数据为什么只有一部分?
$send_snoopy = new Snoopy;
$send_snoopy->rawheaders['Cookie']= $this->cookie;
$send_snoopy->referer = 'https://mp.weixin.qq.com/cgi-bin/getmessage?t=wxm-message&token='.$this->_token.'&lang=zh_CN&count=50';
$url = 'https://mp.weixin.qq.com/cgi-bin/contactmanagepage?t=wxm-friend&token='.$this->_token.'&lang=zh_CN&pagesize=10&pageidx=0&type=0&groupid=0';
$send_snoopy->fetch($url);
$result = $send_snoopy->results;
$this->log('getUsers:'.$result);
if(!$result){
return false;
}
return $result;
/**
* 获取分组列表
*/
public function getfriendlist($groupid=0)
{
$url = "https://mp.weixin.qq.com/cgi-bin/contactmanagepage?t=wxm-friend&lang=zh_CN&pagesize=10&pageidx=0&type=0&groupid=".$groupid."&token=".$this->_token;
$send_snoopy = new Snoopy;
$send_snoopy->rawheaders['Cookie']= $this->cookie;
$send_snoopy->fetch($url);
$response = $send_snoopy->results;
$tmp = "";
if(preg_match('%<script id="json-friendList" type="json/text">([\s\S]*?)</script>%', $response, $match)) {
$tmp = json_decode($match[1], true);
}
return $tmp;
}
正确的account和password,data目录里面的cookie文件也有cert等字段内容
但log里面看到“
现在微信现在对方24小时之内没有主动互动,就不能主动给发送消息,这个有没有办法突破呢?
sendPreview这个函数很有意义,但是没有详细说明,有几个问题想请教:
1、不知道account是什么意思?
2、photoid如何使用现有的图片,哪里获取现有图片的id?
3、photoid如果写成0会怎么样?
$wechat->uploadFile('N:\worksite\zt\zt\zuituware\1.jpg');这样的调用!~
返回错误!~
upload:<script>
document.domain = location.hostname.match(/[^.]?.[^.]?$/);
var
url = window.location.href,
type = url.match(/[?&]type=([^&])/),
formId = url.match(/[?&]formId=([^&])/);
type = type[1] || 0;
formId = formId[1];
top.W.upload.err("上传文件失败", type, formId);
</script>
{ ["ret"]=> string(6) "-20000" ["msg"]=> string(19) "Request is denied! " }
我需要保存为flac文件,才可以支持google voice的api,但是我不知道怎么正确对数据编码,无论是mp3格式还是flac格式,file_put_contents('xx.MP3',$result) 这样保存应该是不行,用格式工厂转换为flac,采样率也配置了,但是google不识别。直接保存为flac也是一样。等待指导。。。。。。。。。求解燃眉之急
如果要输入验证码时就不能发送信息了,请问怎样解决?联系Email:[email protected]
1102行 if ($headerfile) 改成 if (isset($headerfile))
$day 最近几天消息(0:今天,1:昨天,2:前天,3:五天内) 实际上5天以内应该是7 不应该是3 如果为3获取不全消息,7才能完全获取所有的消息
DEBUG: wechat:{
"Ret": 302,
"ErrMsg": "/cgi-bin/home?t=home/index&lang=zh_CN&token=682693245",
"ShowVerifyCode": 0,
"ErrCode": 0
}
DEBUG: wechat:upload:
getTopMsg getMsg 等都无法获取了,是获取的地址改了吗?
getInfo 和 Send 这两个函数获取数据或者发送消息都非常不稳定, 有时候突然可以, 有时候都不行, 这是什么原因呢?是不是微信平台问题? 或者代码问题?
已经成功回复文本消息,没搞明白如何回复图文消息,麻烦看一下下面的程序有什么不对吗?
$newsdata = array(
[0]=>array(
'Title'=>'my title',
'Description'=>'summary text',
'PicUrl'=>'http://www.xxxxx.com/xxx.png',
'Url'=>'http://www.xxxxx.com/xxx'
)
);
$weObj->news($newsdata)->reply();
我查看了返回的XML,里面ArticleCount为什么是0呀?
我需要保存为flac文件,才可以支持google voice的api,但是我不知道怎么正确对数据编码,无论是mp3格式还是flac格式,file_put_contents('xx.MP3',$result) 这样保存应该是不行,用格式工厂转换为flac,采样率也配置了,但是google不识别。直接保存为flac也是一样。等待指导。。。。。。。。。求解燃眉之急
wechatext.class.php中的getTopMsg函数,
$submit = "https://mp.weixin.qq.com/cgi-bin/getmessage?t=ajax-message&lang=zh_CN&count=1&timeline=0&day=0&star=0&cgi=getmessage&offset=0";
这个地址你是哪里抓到的啊,我charles抓半天都没有这个请求。或者有什么方法可以得到这个地址。
我想得到第一个用户怎么办?就是实现一个类似getTopUser这种的。
还有,有什么好办法把FakeId和FromUsrName对应的呢。
很喜欢你写的Lib,
若能回答,感激不尽!
拜lz
应该是weixin把这个接口封了,现在刷二维码提示:未知的二维码,不在是点击登录网页版了。
功能已恢复,应该是服务器出现的暂时性问题。
解决办法:
Snoopy.class.php
在1222行的下面增加一句
if(count($formvars) == 1) return $formvars[0];
即可
例如这样
/**
* 设置发送消息-总调用-发送完成后退出程序
* @param $msg 消息,可以是文本或图文数组或音乐数组
*/
public function send($msg) {
if (is_string($msg)) {
//文字消息
$this->text($msg)->reply();
exit;
} elseif (is_array($msg) && !empty($msg['musicurl'])) {
//音乐消息
$this->music($msg['title'], $msg['desc'], $msg['musicurl'], $msg['hgmusicurl'])->reply();
exit;
} elseif (is_array($msg) && !empty($msg[0]['PicUrl'])) {
//图文消息
$this->news($msg)->reply();
exit;
}
return false;
}
{
"Ret": 400,
"ErrMsg": "",
"ShowVerifyCode": 0,
"ErrCode": -3
}
为了匹配fromusername和fakeid之间的1对1关系,一个思路是让用户在关注公众号之后发送一个全局唯一的信息(如一个昵称),以该唯一信息作为key,找到fromusername和fakeid的关联关系
thinkphp中的$options = array(
0 => array
(
'Title'=>$home['title'],
'Description'=>$home['info'],
'PicUrl'=>$home['picurl'],
'Url'=>$url
)
);
$weixin->news($options);
这里回复图文信息不成功,不知道为什么?求救
此项目是否需要配备tp框架?
在本地xampp下可以正常使用,但放到BAE上以后,就没响应了,是不是某些函数被BAE给禁用导致?还是某些目录没有写权限?比如cookie文件的缓存目录?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.