Commit db9688ec authored by jianghaiming's avatar jianghaiming

update:修改

parent 128a59c3
......@@ -48,6 +48,14 @@ class UserController extends Base
$this->success($userInfo);
}
public function generate_url_linkAction()
{
$params = $this->params;
$user = UserService::generateUrllink($params);
$userInfo['result'] = $user;
$this->success($userInfo);
}
}
\ No newline at end of file
......@@ -279,6 +279,46 @@ class UserService
return $update;
}
public static function generateUrllink()
{
//请求接口,获取用户openid
$generateUrl = 'https://api.weixin.qq.com/wxa/generate_urllink?access_token='.self::getAccessToken();
$params = [
'access_token' => self::getAccessToken(),
];
$params = [
"path" => "/pages/product-info/index",
"query" => "marketing_id=10000107&from=square",
"is_expire" => true,
"expire_type" => 1,
"expire_interval" => 10,
];
$response = (new Request())->post($generateUrl, $params,5000,'json');
$jsoninfo = $response['response'];
return $jsoninfo;
}
/**
* 获取accessToken
* @return mixed
*/
public static function getAccessToken()
{
$appid = \Yaf\Registry::get('config')->wechat->appid;
$appsecret = \Yaf\Registry::get('config')->wechat->secret;
$url = "https://api.weixin.qq.com/cgi-bin/token";
$params = [
'grant_type' => 'client_credential',
'appid' => $appid,
'secret' => $appsecret,
];
$response = (new Request())->get($url, $params);
$jsoninfo = $response['response'];
$accessToken = $jsoninfo["access_token"];
return $accessToken;
}
private static function generate3rdSession($openid) {
return md5(mt_rand() . $openid);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment