예제 #1
0
<?php 
require "config.php";
require "include/WeiXin.php";
$weiXin = new WeiXin($G_CONFIG['weiXin']);
$lastMsg = $weiXin->getLatestMsgs();
//print_r($lastMsg);
$file = $lastMsg[0]['fakeid'] . '.jpg';
if (is_readable($file) == false) {
    $weiXin->getPicture($lastMsg[0]['fakeid']);
}
if ($lastMsg[0][type] == '1') {
    $messageid = $lastMsg[0]['id'];
    $fakeid = $lastMsg[0]['fakeid'];
    $nicheng = $lastMsg[0]['nick_name'];
    $content = $lastMsg[0]['content'];
    $nicheng = strip_tags($nicheng);
    $content = strip_tags($content);
    $content = @str_replace(array('"', '\'', '゛', '&nbsp;'), array('', '', '', ''), $content);
    $nicheng = @str_replace(array('"', '\'', '゛', '&nbsp;'), array('', '', '', ''), $nicheng);
    $imgurl = Web_ROOT . '/moni/' . $fakeid . '.jpg';
    $result = mysql_query("SELECT * FROM  `weixin_wall` WHERE  `fakeid` = '{$fakeid}'");
    $row = mysql_fetch_array($result, MYSQL_ASSOC);
    /* $sql = "INSERT INTO `weixin_wall` (`id`,`messageid`,`fakeid`,`num`,`content`,`nickname`,`avatar`,`ret`,`status`) VALUES (NULL,'$messageid','$fakeid ','-1','$content','$nicheng','$imgurl','0','0')";
    mysql_query($sql); */
    $sql_num = "SELECT * FROM  `weixin_wall_num` ";
    $query_num = mysql_query($sql_num);
    $q = mysql_fetch_row($query_num);
    $num = $q[0];
    $sql = "INSERT INTO `weixin_wall` (`id`,`messageid`,`fakeid`,`num`,`content`,`nickname`,`avatar`,`ret`,`status`) VALUES (NULL,'{$messageid}','{$fakeid} ','{$num}','{$content}','{$nicheng}','{$imgurl}','1','0')";
    mysql_query($sql);
    $sql_num = "UPDATE `weixin_wall_num` SET `num` = `num`+1";
예제 #2
0
require "config.php";
require "include/WeiXin.php";
$weiXin = new WeiXin($G_CONFIG['weiXin']);
$testFakeId = "160628835";
$testFakeId2 = "2158620204";
echo "<pre>";
// echo '发送消息</br>';
// print_r($weiXin->send($testFakeId, "test"));
// echo '发送图片, 图片必须要先在公共平台中上传, 得到图片Id</br>';
// print_r($weiXin->sendImage($testFakeId, "10000001"));
// echo '批量发送</br>';
// print_r($weiXin->batSend(array($testFakeId, $testFakeId2), "test batSend"));
echo '得到用户信息</br>';
print_r($weiXin->getUserInfo($testFakeId));
echo '得到最新消息,默认获取第一页消息</br>';
$latestMsgs = $weiXin->getLatestMsgs();
print_r($latestMsgs);
if ($latestMsgs) {
    echo $latestMsgs[0]['fakeid'], '</br>';
    echo $latestMsgs[0]['date_time'], '</br>';
    echo $latestMsgs[0]['content'], '</br>';
}
// 这个是可以得到的 只是 getLatestMsgs 这个抓取不太稳定,不能频繁去抓取
// echo '得到用户Fakeid</br>';
// $userFakeId = $weiXin->getLatestMsgByCreateTimeAndContent($createTime, $content);
// print_r($userFakeId);
// echo "开启高级模式</br>";
// $openAdvancedSwitch = $weiXin->openAdvancedSwitch('1');
// // print_r($openAdvancedSwitch);
// echo $openAdvancedSwitch['base_resp']['err_msg'] == 'ok' ? '开启成功' : '开启失败','</br>';
// echo "绑定</br>";