RoutineCode.php 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. <?php
  2. namespace app\routine\model\routine;
  3. class RoutineCode{
  4. /**
  5. * 获取分销二维码
  6. * @param int $uid yonghuID
  7. * @param array $color 二维码线条颜色
  8. * @return mixed
  9. */
  10. public static function getCode($uid = 0,$color = array()){
  11. $accessToken = RoutineServer::get_access_token();
  12. $url = "https://api.weixin.qq.com/wxa/getwxacodeunlimit?access_token=".$accessToken;
  13. if($uid) $data['scene'] = $uid;
  14. else $data['scene'] = 0;
  15. if(empty($color)){
  16. $color['r'] = 0;
  17. $color['g'] = 0;
  18. $color['b'] = 0;
  19. }
  20. $data['page'] = '';
  21. $data['width'] = 430;
  22. $data['auto_color'] = false;
  23. $data['line_color'] = $color;
  24. $data['is_hyaline'] = false;
  25. return RoutineServer::curlPost($url,json_encode($data));
  26. }
  27. /**
  28. * 获取小程序内访问页面的二维码
  29. * @param string $path
  30. * @param int $width
  31. * @return mixed
  32. */
  33. public static function getPages($path = '',$width = 430){
  34. $accessToken = RoutineServer::get_access_token();
  35. $url = "https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=".$accessToken;
  36. $data['path'] = $path;
  37. $data['width'] = $width;
  38. return RoutineServer::curlPost($url,json_encode($data));
  39. }
  40. }