php-判断是否关注微信公众号

<?php

    header("Content-type: text/html; charset=utf-8");

    $access_token = "https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=XXXX&secret=XXXX";
    $access_msg = json_decode(file_get_contents($access_token));
    $token = $access_msg->access_token;
    $openids = 'xxxx';
    $subscribe_msg = "https://api.weixin.qq.com/cgi-bin/user/info?access_token=$token&openid=$openids";
    $subscribe = json_decode(file_get_contents($subscribe_msg));
    $gzxx = $subscribe->subscribe;

   if($gzxx === 1){
       echo "已关注";
   }else{
       echo "未关注";
   };
?>

posted @ 2018-09-18 17:13  你不知道我  阅读(1765)  评论(0编辑  收藏  举报