error_reporting(E_ALL);
require "conn.php";
$appid = 'xxxxx';
$redirect_uri=urlencode("http://www.xxxxx.com/weixin/rukou.php/" );
$url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$appid."&redirect_uri=".$redirect_uri."&response_type=code&scope=snsapi_base&state=cooo#wechat_redoect# ";
header('location',$url);
$appsecret = 'xxxxx';
$code = $_GET['code'];
$get_token_url="https://api.weixin.qq.com/sns/oauth2/access_token?appid=".$appid. "&secret=".$appsecret."&code=".$code."&grant_type=authorization_code";
$access_token=$jsonobj['access_token'];
$openid=$jsonobj['openid'];
//檢查資料庫中是否有openid
mysql_select_db("sjk", $dzcon); utf8',$dzcon);
$sqlcha="從weixinopenid=$openid 的使用者中選擇id";
if (is_null(mysql_query($sqlcha, $dzcon))) {
雷雷
雷雷
$userobj=json_decode($res,true);$nickname=$userobj['nickname'];
$date=date("y-m-d h:i:s");
$sqlzhuce="插入使用者(weixinhao,weixinniheng,zhucetime)values('$openid','$nickname','$date')";
if (!mysql_query($sqlzhuce,$dzcon)) {
if (!mysql_query($sqlzhuce,$dzcon)) {
}
$sqldenglu="select id from user where weixinhao=$openid";
$userids=mysql_query($sqldenglu,$dzcon);
$userid=mysql_fetch_array($userids); _SESSION['userid']=$userid[0];
echo "<script>window.location.href=index.php?userid=".$_SESSION['userid']";</script>";
mysql_close ($dzcon);
? >
回覆內容:
error_reporting(E_ALL);require "conn.php";$appid = 'xxxxx';
$redirect_uri=urlencode("http://www.xxxxx.com/weixin/rukou.php/" );
$url="https://open.weixin.qq.com/connect/oauth2/authorize?appid=".$appid."&redirect_uri=".$redirect_uri."&response_type=code&scope=snsapi_base&state=cooo#wechat_redoect# ";
header('location',$url);
$appsecret = 'xxxxx';
$code = $_GET['code'];
雷雷
$access_token=$jsonobj['access_token'];
$openid=$jsonobj['openid'];
mysql_select_db("sjk", $dzcon); utf8',$dzcon);
$sqlcha="從使用者中選取id,其中weixinopenid=$openid";
if (is_null(mysql_query($sqlcha, $dzcon))) {
雷雷
}其他{
雷雷
$userobj=json_decode($res,true);
//日期
$date=date("y-m-d h:i:s");
$sqlzhuce="插入使用者(weixinhao,weixinniheng,zhucetime)values('$openid','$nickname','$date')";
if (!mysql_query($sqlzhuce,$dzcon)) {
雷雷}
$sqldenglu="select id from user where weixinhao=$openid";
$userid=mysql_fetch_array($userids); _SESSION['userid']=$userid[0];
echo "<script>window.location.href=index.php?userid=".$_SESSION['userid']";</script>";
mysql_close ($dzcon);
? >
報錯誤是什麼,放在http://mp.weixin.qq.com/debug/調試下報錯