...
|
...
|
@@ -43,7 +43,7 @@ class ShareController extends WeChatBaseController |
|
|
$savePath = './upload/'.$webPath;
|
|
|
//生成带参二维码
|
|
|
if(!file_exists($savePath)){
|
|
|
$prcode_url = $this->get_code($user_id,$url);
|
|
|
$prcode_url = $this->code_img($user_id,$url);
|
|
|
}
|
|
|
//保存头像
|
|
|
$avatar=$this->getImage($user['avatar'],'avatar_'.$user['id']);
|
...
|
...
|
@@ -186,6 +186,69 @@ class ShareController extends WeChatBaseController |
|
|
return false;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
public function code_img($my_user_id,$status){
|
|
|
//生成带参二维码
|
|
|
$savePath=ROOT_PATH.'public/upload/qrcode/';
|
|
|
if (!file_exists($savePath)){
|
|
|
mkdir($savePath, 0777,true);
|
|
|
}
|
|
|
$code_img = $this->code_img1($my_user_id,$status);
|
|
|
$code = file_get_contents($code_img);
|
|
|
file_put_contents(ROOT_PATH."public/upload/qrcode/code_img28.png",$code);
|
|
|
return $savePath.'code_img28.png';
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 生成带参二维码
|
|
|
*/
|
|
|
public function code_img1($admin_id,$status)
|
|
|
{
|
|
|
$options=config('wechat_config');
|
|
|
$app = new Application($options);
|
|
|
$accessToken = $app->access_token; // EasyWeChat\Core\AccessToken 实例
|
|
|
$token = $accessToken->getToken(false);
|
|
|
$url = 'https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=' . $token;
|
|
|
$param = [
|
|
|
'expire_seconds' => '',
|
|
|
'action_name' => 'QR_LIMIT_STR_SCENE',
|
|
|
'action_info' => ['scene' => ['scene_str' => "$admin_id"."-"."$status"]]
|
|
|
];
|
|
|
$result = $this->api_notice_increment($url, json_encode($param));
|
|
|
$data = json_decode($result, true);
|
|
|
$ticket = urlencode($data['ticket']);
|
|
|
$qr_url = 'https://mp.weixin.qq.com/cgi-bin/showqrcode?ticket=' . $ticket;
|
|
|
return $qr_url;
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 获取二维码提交
|
|
|
*/
|
|
|
public function api_notice_increment($url, $data)
|
|
|
{
|
|
|
// $data=json_encode($data);
|
|
|
$ch = curl_init();
|
|
|
$header = array("Accept-Charset: utf-8");
|
|
|
curl_setopt($ch, CURLOPT_URL, $url);
|
|
|
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
|
|
|
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
|
|
|
curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
|
|
|
curl_setopt($ch, CURLOPT_USERAGENT, 'Mozilla/5.0 (compatible; MSIE 5.01; Windows NT 5.0)');
|
|
|
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
|
|
|
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
|
|
|
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
|
|
|
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
|
|
|
$tmpInfo = curl_exec($ch);
|
|
|
if (curl_errno($ch)) {
|
|
|
curl_close($ch);
|
|
|
return $ch;
|
|
|
} else {
|
|
|
curl_close($ch);
|
|
|
return $tmpInfo;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 下载微信头像保存到本地
|
|
|
* @param $url
|
...
|
...
|
|