95 lines
2.7 KiB
PHP
95 lines
2.7 KiB
PHP
<?php
|
||
namespace app\api\wxapi\post;
|
||
|
||
use app\api\wxapi\Base;
|
||
/* 生成带参数的二维码
|
||
* $QrcodeCreatePost=new QrcodeCreatePost();
|
||
* $QrcodeCreatePost->setAccessToken($AccessTokenRequest->access_token);
|
||
* $QrcodeCreatePost->setActionName(QrcodeCreatePost::ACTION_NAME_QR_SCENE);
|
||
* $QrcodeCreatePost->setExpireSeconds(60*60); //临时时间戳
|
||
* $QrcodeCreatePost->setSceneVal('123');
|
||
* $QrcodeCreatePost->run();
|
||
* $WxClient->setTypeCurl(WxClient::TYPE_CURL_POST);
|
||
* $QrcodeInfo=$WxClient->execute($QrcodeCreatePost);
|
||
* */
|
||
class QrcodeCreatePost extends Base
|
||
{
|
||
const ACTION_NAME_QR_SCENE='QR_SCENE'; //临时(32位非0整型)
|
||
const ACTION_NAME_QR_LIMIT_SCENE='QR_LIMIT_SCENE'; //永久(最大值为1--100000)
|
||
const ACTION_NAME_QR_LIMIT_STR_SCENE='QR_LIMIT_STR_SCENE'; //永久字符串(长度限制为1到64)
|
||
private $PostParas = array(); //post参数
|
||
private $GetParas = array(); //请求地址参数
|
||
private $access_token;
|
||
private $expire_seconds; //该二维码有效时间,以秒为单位。 最大不超过2592000(即30天),此字段如果不填,则默认有效期为30秒。(临时二维码参数)
|
||
private $action_name; //ACTION_NAME_QR_SCENE(临时) ACTION_NAME_QR_LIMIT_SCENE(永久) ACTION_NAME_QR_LIMIT_STR_SCENE(永久字符串)
|
||
private $scene_val; //场景值
|
||
|
||
public function init(){
|
||
|
||
}
|
||
|
||
public function run(){
|
||
switch ($this->action_name) {
|
||
case self::ACTION_NAME_QR_LIMIT_STR_SCENE;
|
||
$this->PostParas["action_info"]['scene']['scene_str'] = $this->getSceneVal();
|
||
break;
|
||
default :
|
||
$this->PostParas["action_info"]['scene']['scene_id'] = $this->getSceneVal();
|
||
}
|
||
|
||
}
|
||
|
||
public function getApiMethodName(){
|
||
return "cgi-bin/qrcode/create";
|
||
}
|
||
|
||
public function getApiParas(){
|
||
return json_encode($this->PostParas);
|
||
}
|
||
|
||
public function getGetParas(){
|
||
return $this->GetParas;
|
||
}
|
||
|
||
public function putOtherTextParam($key, $value){
|
||
$this->PostParas[$key] = $value;
|
||
$this->$key = $value;
|
||
}
|
||
|
||
public function setExpireSeconds($expire_seconds){
|
||
$this->expire_seconds = $expire_seconds;
|
||
$this->PostParas["expire_seconds"] = $expire_seconds;
|
||
}
|
||
|
||
public function getExpireSeconds(){
|
||
return $this->expire_seconds;
|
||
}
|
||
|
||
public function setActionName($action_name){
|
||
$this->action_name = $action_name;
|
||
$this->PostParas["action_name"] = $action_name;
|
||
}
|
||
|
||
public function getActionName(){
|
||
return $this->action_name;
|
||
}
|
||
|
||
public function setSceneVal($scene_val){
|
||
$this->scene_val = $scene_val;
|
||
}
|
||
|
||
public function getSceneVal(){
|
||
return $this->scene_val;
|
||
}
|
||
|
||
public function setAccessToken($access_token){
|
||
$this->access_token = $access_token;
|
||
$this->GetParas["access_token"] = $access_token;
|
||
}
|
||
|
||
public function getAccessToken(){
|
||
return $this->access_token;
|
||
}
|
||
|
||
}
|