怎么生成二维码,创建标签?

生成二维码: 每次创建二维码ticket需要提供一个开发者自行设定的参数(scene_id)
生成临时二维码:
http请求方式: POST
URL: https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN

生成永久二维码:
http请求方式: POST
URL: https://api.weixin.qq.com/cgi-bin/qrcode/create?access_token=TOKEN
public function qrcodeAdd(){
       if(IS_GET){
       	$this->display('qrcode_add');
       }else{
       	$mp=$this->mp;
       	$arr=I('post.');
       	$arr['mp_id']=$mp['id'];
       	$id=M('mp_qrcode')->add($arr);
       	include APP_PATH .'LaneWeChat/lanewechat.php';
       	$ret=Popularize::createTicket($arr['type'],$arr['expire'],$arr['scene_str']);
        // dump($ret);
        // exit;
       	if(isset($ret['ticket'])){
       		$qrcodefile=Popularize::getQrcode($ret['ticket']);
       		$ret['src']= ($qrcodefile);
          // dump($ret);
          // exit;
       		$ret['create_time']=time();
          // dump($ret);
          // exit;
       		M('mp_qrcode')->where("id=$id")->save($ret);
       		$this->ajaxReturn(array('status'=>1,'msg'=>'ok','url'=>U('qrcode')));
       	}else{
       		$this->ajaxReturn(array('status'=>0,'msg'=>$ret));
       	}
       }
}


创建用户标签:
https://api.weixin.qq.com/cgi-bin/tags/create?access_token=ACCESS_TOKEN
正常返回json格式:
{   "tag":{ "id":134,//标签id "name":"广东"   } }

创建一个createTag方法

public function createTag(){
    $mp = $this->mp;
    $tagname = "六一";
    $where['mp_id'] = $mp['id'];
    $where['tag'] = $tagname;
    $data = M("mp_tags")->where($where)->find();
    // echo $data;
    // exit;
    if(empty($data)){
      $api = "https://api.weixin.qq.com/cgi-bin/tags/create?access_token=" . getAccess_token();
      $arr = array();
      $arr['tag']['name'] = $tagname;
      $json = json_encode($arr,JSON_UNESCAPED_UNICODE);
      // echo $json;
      // exit;
      include APP_PATH . 'LaneWeChat/lanewechat.php';
      // $ret = \LaneWeChat\Core\Curl::callWebServer($api,$json,'POST');
      $ret = Curl::callWebServer($api,$json,'POST',1,0);
      // dump($ret);
      // exit;
      if($ret['tag']){
        $row['mp_id'] = $mp['id'];
        $row['tag_id'] = $ret['tag']['id'];
        $row['tag'] = $ret['tag']['name'];
        // dump($row);
        M('mp_tags')->add($row);
      }
    }
  }

你可能感兴趣的:(怎么生成二维码,创建标签?)