$url = 'http://xxxx.com/test/aaaa/index.php';//开发者url $token = 'weixin';//token $timestamp = $_get["timestamp"]; $nonce = $_get["nonce"]; $tmparr = array($token, $timestamp, $nonce); sort($tmparr, sort_string); $tmpstr = implode( $tmparr ); $tmpstr = sha1( $tmpstr ); $url .= stripos($url, '?') === false ? '?' : '&'; $url .= http_build_query(array( 'signature' => $tmpstr, 'timestamp' => $timestamp, 'nonce' => $nonce, )); //echo $url; //如果不是项目相关的事件 $returnstr返回空 $header = array(); //这个要加上啊 $header[] = "content-type: text/xml";//定义content-type为xml $ch = curl_init(); curl_setopt($ch, curlopt_url, $url); curl_setopt($ch, curlopt_returntransfer, 1); curl_setopt($ch, curlopt_httpheader, $header); curl_setopt($ch, curlopt_post, 1); curl_setopt($ch, curlopt_postfields, $poststr); //curl_setopt($ch, curlopt_postfields, $pp); $response = curl_exec($ch); if(curl_errno($ch)){ error_log (curl_error($ch)); } curl_close($ch); echo $response;//返回给微信服务器
相关推荐:
关于开发者模式的10篇文章推荐
微信成为开发者模式
微信开发者模式和新浪sae之间 token总是验证失败
以上就是php实现模拟微信公众号开发者模式的详细内容。
