首页 > php教程 > PHP源码 > 正文

天天AV - 微信公众平台 - 实例

PHP中文网
发布: 2016-05-25 17:06:22
原创
6465人浏览过

如何部署自己的公众平台: 
    1.打开http://mp.weixin.qq.com 注册/登录 
    2.进入高级功能菜单,选择编辑模式或开发者模式(本例子属于开发者模式-需要自己拥有服务器) 
    3.进入开发者模式,注册成为开发者,配置接口信息。如: 
        url:http://192.168.1.1/wx_sample.php 
        token:weixin (自己填写一个) 
    4.打开wx_sample.php    $wechatobj->valid(); 这个方法进行验证 
    5.验证成功,关闭wx_sample.php    $wechatobj->valid(); 
    6.马上使用手机,访问属于自己的公众平台吧 


本例代码测试方法: 
    1.打开手机微信 
    2.关注公众账号:天天av 
    3.发送一条信息:q北京遇上西雅图 
    4.返回一条磁力链接 
    5.系统返回的是迅雷磁力链接,请您使用电脑版迅雷或手机版迅雷,进行下载观看 

原理: 

    1.接收用户数据,如:q北京遇上西雅图 

    2.到bt搜索引擎进行查询数据 

    3.返回一条磁力链接 

    ps:由于没有申请到内测资格,有很多功能都受到限制,如:5秒超时解决不了, 

    无法主动推送,批量推送,模拟登录又不方便等等。。。 

支点微信墙程序 F2.0
支点微信墙程序 F2.0

支点微信墙F2.0推出了!在前段时间推出的F1.0的基础上,新加了微信摇一摇和启动仪式的功能。修复了微信墙无默认头像的功能,修复了微抽奖的BUG,修复了微信公众平台有时接收信息不回复的功能。(原F1.0功能介绍:现场关注主办方微信公众号,粉丝迅速涨,让大家都High起来吧!互动加粉,触手可得!微信墙文字抽奖,一墙搞定!通过微信平台,你可以实现文字讨论,更能够实现投票,对对碰,交换名片等趣味性和互动

支点微信墙程序 F2.0 0
查看详情 支点微信墙程序 F2.0
<?php
/**
  * wechat php test
  */
header('Content-Type:text/html;charset=utf8');
date_default_timezone_set('RPC');
 
//define your token
define("TOKEN", "2snH21PBqF7UK");//自定义
$wechatObj = new wechatCallbackapiTest();
//$wechatObj->valid();//第一次验证token时使用
$wechatObj->responseMsg();
 
class wechatCallbackapiTest
{
    private $keyword;
     
    public function valid()
    {
        $echoStr = $_GET["echostr"];
 
        //valid signature , option
        if($this->checkSignature()){
            echo $echoStr;
            exit;
        }
    }
     
    public function responseMsg()
    {
        //get post data, May be due to the different environments
        $postStr = $GLOBALS["HTTP_RAW_POST_DATA"];
 
        //extract post data
        if (!empty($postStr)){
                 
                $postObj = simplexml_load_string($postStr, 'SimpleXMLElement', LIBXML_NOCDATA);
                $fromUsername = $postObj->FromUserName;
                $toUsername = $postObj->ToUserName;
                $this->keyword = trim($postObj->Content);
                $time = time();
                $textTpl = "<xml>
                            <ToUserName><![CDATA[%s]]></ToUserName>
                            <FromUserName><![CDATA[%s]]></FromUserName>
                            <CreateTime>%s</CreateTime>
                            <MsgType><![CDATA[%s]]></MsgType>
                            <Content><![CDATA[%s]]></Content>
                            <FuncFlag>0</FuncFlag>
                            </xml>";             
                if(!empty( $this->keyword ))
                {
                    if($this->keyword == 999){
                        $msgType = "text";
                        $contentStr = '当您搜索:q北京遇上西雅图,系统返回的是迅雷磁力链接,请您使用电脑版迅雷或手机版迅雷,进行下载观看。';//'参数:1, 按下载数查询;参数:2, 按时间查询;参数:5, 按质量查询; 精确查询请添加双引号; 例如: q"北京遇上西雅图"  1';
                        echo $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
                        exit;
                    }
                    preg_match('#^q(.*)#', $this->keyword, $str);
                    if($str[1]){
                        $data = $this->getQueryParam($str[1]);
                        $contents = $this->getQueryList($data);
                        $resutl = $this->getQueryResult($contents);
                        $link = str_replace('&','&',urldecode($resutl[1]));//组装磁力链接
                        if($link){
                            $msgType = "text";
                            $contentStr = $link;
                            echo $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
                        }
                    }else{
                        $msgType = "text";
                        $contentStr = '请您输入q进行查询,例如: q北京遇上西雅图     更多帮助请输入999';
                        echo $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);
                    }
                }else{
                    echo "Input something...";
                }
 
        }else {
            echo "";
            exit;
        }
         
    }
         
    private function checkSignature()
    {
        $signature = $_GET["signature"];
        $timestamp = $_GET["timestamp"];
        $nonce = $_GET["nonce"];    
                 
        $token = TOKEN;
        $tmpArr = array($token, $timestamp, $nonce);
        sort($tmpArr);
        $tmpStr = implode( $tmpArr );
        $tmpStr = sha1( $tmpStr );
         
        if( $tmpStr == $signature ){
            return true;
        }else{
            return false;
        }
    }
     
    //返回q=查询
    function getQueryResult($contents){
        $result = array();
        preg_match('#<a onclick="fclck\(this.href\)" href="(.*)" title="Download via magnet-link">\[magnet-link\]</a>#iUs', $contents, $content);
        $result = $content;
        return $result;
    }
     
     
    //获取btdigg.org 的查询数据
    function getQueryList($data){
        $data['order'] = $data['order'] ? $data['order'] : 0;
        $data['p'] = 0;
        $ch = curl_init();
 
        curl_setopt($ch, CURLOPT_URL, 'https://btdigg.org/search?'.http_build_query($data));
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($ch, CURLOPT_USERAGENT, 'Google Bot');
        curl_setopt($ch, CURLOPT_TIMEOUT, 4);
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_FRESH_CONNECT, true);
         
        $result = curl_exec($ch);
        curl_close($ch);
        return $result;
    }
 
    //获取查询参数
    function getQueryParam($str){
        $data = array();
        $string = explode(' ', $str);
         
        //是数组 and 最后一个数组是数字
        $last = array_pop($string);
        if(is_numeric($last)){
            $data['q'] = implode(' ', $string);
            $data['order'] = $last;
        }else{
            $data['q'] = $str;
        }
        return $data;
    }
     
}
 
?>
登录后复制
微信app下载
微信app下载

微信是一款手机通信软件,支持通过手机网络发送语音短信、视频、图片和文字。微信可以单聊及群聊,还能根据地理位置找到附近的人,带给大家全新的移动沟通体验,有需要的小伙伴快来保存下载体验吧!

下载
来源:php中文网
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系admin@php.cn
作者最新文章
最新问题
热门推荐
开源免费商场系统广告
热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 举报中心 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号