Get user Information
Private Function Ulikegetuserinfo ($Wechat, $data)
{
$this->logger ("Reach Ulikegetuserinfo in UlikeFunction.inc.php");
$access _token= $this->get_token ();
$openid = $data [' Fromusername '];
$this->logger ("Fromusername is:" $data [' fromusername ']);
$url = "https://api.weixin.qq.com/cgi-bin/user/info?access_token= $access _token&openid= $openid &LANG=ZH_CN ";
$this->logger ("URL is:". $url);
$jsonInformation = $this->http_curl ($url);
$this->logger ($jsonInformation);
$UserarrInformation =json_decode ($jsonInformation, true);
$this->logger ("Userarrinformation is:". $UserarrInformation);
$this->insertuserinformation ($UserarrInformation, $Wechat);
}
Perform database interpolation
Private Function Insertuserinformation ($User, $Wechat)
{
$this->logger ("reached the database for interpolation processing!");
$this->logger ($User [' OpenID ']);
$link =mysql_connect ("127.0.0.1", "Root", "" ");
if ($link)
{
$this->logger ("database connection succeeded");
}else{
$this->logger ("Database connection failed");
}
mysql_select_db ("Weixin", $link);
$sql = "INSERT into Ulikeuser values (' {$User [" OpenID "]} ', ' {$User [" nickname "]} ', ' {$User [" Sex "]} ', ' {$User [" City "]} ', ' {$User ["Province"]} ', ' {$User ["Headimgurl"]} ', ' ". Time ()." ') ";
$sql = "INSERT into Info values (' Lang ', ' 21 ', ' Boys ')";
$sql 2= "Select sex from Info where name= ' lilang1 '";
mysql_query ($sql, $link);
mysql_query ("Set names ' UTF8 '");//Do not join will appear garbled
$result =mysql_query ($sql, $link);
if ($result)
{$this->logger ("You have executed the database file! ". $result);}
Else
{
$this->logger ("Your data has not been inserted successfully! ");
}
Mysql_close ($link);
}
PHP WAMPP Accessing the database