• Resolved rogerxincn

    (@rogerxincn)


    hi there,
    Two problems in my wp weixin.
    1,fored follower works while the QR code still showed as before only until user refresh it in weixin brower, or go back to the weblink and click to entry in.
    2,the setting of server setting, plugin suggestted using, https://www.XXX.com/weixin-responder, it not works. https should be http, and the whole link needs to be https://www.XXX.com/weixin-responder.php, and I googled find the code in weixin-responder.php listed here may help others.

    <?php  
    
    //define your token  
    
    define("TOKEN", "featured token");  
    
    $wechatObj = new wechatCallbackapiTest();  
    
    $wechatObj->valid();  
    
       
    
    class wechatCallbackapiTest  
    
    {  
    
        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;  
    
                    $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( $keyword ))  
    
                    {  
    
                        $msgType = "text";  
    
                        $contentStr = "Welcome to wechat world!";  
    
                        $resultStr = sprintf($textTpl, $fromUsername, $toUsername, $time, $msgType, $contentStr);  
    
                        echo $resultStr;  
    
                    }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;  
    
            }  
    
        }  
    
    }  
    
       
    
    ?>
    

    not sure it right or not, but finally token passed by WEIXIN.
    My problem is the welcome information and the welcome image doesn’t show, any further movement should be done?
    Thanks.

    Just have scanned your personally weixin account for details. Roger(大帅).

    Regards
    Roger(大帅)

Viewing 1 replies (of 1 total)
  • Plugin Author Alexandre Froger

    (@frogerme)

    Hello @rogerxincn !
    I’ll leave a comment here for historical purposes.
    As discussed on WeChat, the main issue you faced had to do with the configuration of the WeChat Responder.
    WP Weixin assumes the website is using https because that’s the right thing to do (and is required by law in China when dealing with user information).

    1 – force follow: the refresh button simply refreshes the page to see if the user has indeed followed the Official Account ; if not, the same QR Code is displayed over and over (hence “force”). This behavior can be altered with template override and filter hooks (as a basic example, override the template to change the link of the refresh button with a GET parameter, and a rule in wp_weixin_auth_needed filter hook not to ask for authentication when the specified GET parameter is in the URL) ; by default it is useful when the user is coming back to the page without reloading it with the “back” button after having followed the Official Account.

    2 – responder: in your case, the URL to configure was https://www.XXX.com/weixin-responder (without https). weixin-responder is an existing endpoint for the responder, and using a custom PHP script like described does not only bypasses all the WP Weixin Responder feature and replaces it with the custom logic, it is also potentially unsafe (prevents WordPress from capturing the request and sanitizing it) and not recommended. To extend the responder, it is recommended to use the wp_weixin_responder action hook instead.

    For further information regarding extending WP Weixin’s behavior, developers can refer to the full documentation linked in the plugin’s description.

    I was glad to talk to you and help setting up WP Weixin on your website.

Viewing 1 replies (of 1 total)
  • The topic ‘Two problems faced by this plugin’ is closed to new replies.