微信生成带参数二维码 关注公众号

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
$openid $_W['openid'];
//get user id
$sql "select id from ims_meepo_online_user where openid = '$openid'";
$user_id = pdo_fetchcolumn($sql);
$token $this->getAccessToken();
$data array(
    'expire_seconds'=>604800,
    'action_name'=>'QR_SCENE',
    'action_info'=>array(
        'scens'=>array(
            'user_id'=>$user_id
        )
    )
);
 
$data = json_encode($data);
//$response = ihttp_request("https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=".$token, $data);
//print_r($response);
 
 
$url "https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=" $token;
$ch1 = curl_init();
curl_setopt($ch1, CURLOPT_URL, $url);
curl_setopt($ch1, CURLOPT_POST, 1);
curl_setopt($ch1, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch1, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch1, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch1, CURLOPT_POSTFIELDS, $data);
$c = curl_exec($ch1);
 
$result = @json_decode($c, true);
if( !is_array($result) )
{
return false;
}
 
if( !empty($result["errcode"]) )
{
return error(-1, $result["errmsg"]);
}
 
$ticket $result["ticket"];
 
$img 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket='.$ticket;
 
echo '<img src="'.$img.'">';

微擎

api.php

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
$input file_get_contents('php://input');
$myfile fopen("newfile.txt""w"or die("Unable to open file!");
 
$array = xmlToArray($input);
$EventKey $array['EventKey'];
 
$s explode('_'$EventKey);
$recom_id $s[1];
 
$user_openid $array['FromUserName'];
fwrite($myfile$input);
fclose($myfile);
 
if(!empty($user_openid) && !empty($recom_id)){
    $user_data array(
        'openid'=> $user_openid,
        'recommend_id' => $recom_id
    );
    pdo_insert('meepo_online_user_relationship',$user_data);
}

__init__.php

1
2
3
4
5
6
7
8
9
10
//get relationship from tablename
        if(!empty($openid)){
            echo $openid;
             
            $recommend_id = pdo_fetchcolumn("SELECT `recommend_id` FROM `ims_meepo_online_user_relationship` WHERE openid=:openid",array(':openid' =>$openid));
            if(!empty($recommend_id)){
                $data['one'] = $recommend_id;
                $send_msg 'Y';
            }
        }