WeChat 애플릿 PHP는 매개변수를 사용하여 QR 코드를 생성합니다
애플릿 페이지 API 공식 획득
미니 프로그램 매개변수 QR 코드 API가 제공하는 도움말이 제한적이어서 이 기능에 대한 저의 이해는 다음과 같습니다
주로 thinkphp 백그라운드 인터페이스를 통해 구현하며, 코드는 다음과 같습니다
1. 먼저 ACCESS_TOKEN을 받으세요:
$tokenUrl="https://api.weixin.qq.com/cgi-bin/token?grant_type=client_credential&appid=".$this->appid."&secret=".$this->secret; $getArr=array(); $tokenArr=json_decode($this->send_post($tokenUrl,$getArr,"GET")); $access_token=$tokenArr->access_token;
send_post:
function send_post($url, $post_data,$method='POST') { $postdata = http_build_query($post_data); $options = array( 'http' => array( 'method' => $method, //or GET 'header' => 'Content-type:application/x-www-form-urlencoded', 'content' => $postdata, 'timeout' => 15 * 60 // 超时时间(单位:s) ) ); $context = stream_context_create($options); $result = file_get_contents($url, false, $context); return $result; }
2, QR 코드 생성:
$path="pages/index?query=1"; $width=430; $post_data='{"path":"'.$path.'","width":'.$width.'}'; $url="https://api.weixin.qq.com/cgi-bin/wxaapp/createwxaqrcode?access_token=".$access_token; $result=$this->api_notice_increment($url,$post_data);
api_notice_increment:
function api_notice_increment($url, $data){ $ch = curl_init(); $header = "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($curl, 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); // var_dump($tmpInfo); // exit; if (curl_errno($ch)) { return false; }else{ // var_dump($tmpInfo); return $tmpInfo; } }
3. return 바이너리 데이터에서 이미지를 생성하고 자신의 서버에 업로드
주 코드:
file_put_contents($filepath, $result)
서비스 부품 코드 업로드, 더 이상 게시되지 않습니다! 읽어주셔서 감사합니다. 이 내용이 모든 사람에게 도움이 되기를 바라며 이 사이트를 지원해 주셔서 감사합니다!
매개변수를 사용하여 QR 코드를 생성하는 WeChat 애플릿 PHP와 관련된 더 많은 기사를 보려면 PHP 중국어 웹사이트를 주목하세요!

핫 AI 도구

Undresser.AI Undress
사실적인 누드 사진을 만들기 위한 AI 기반 앱

AI Clothes Remover
사진에서 옷을 제거하는 온라인 AI 도구입니다.

Undress AI Tool
무료로 이미지를 벗다

Clothoff.io
AI 옷 제거제

AI Hentai Generator
AI Hentai를 무료로 생성하십시오.

인기 기사

뜨거운 도구

SublimeText3 중국어 버전
중국어 버전, 사용하기 매우 쉽습니다.

Atom Editor Mac 버전 다운로드
가장 인기 있는 오픈 소스 편집기

VSCode Windows 64비트 다운로드
Microsoft에서 출시한 강력한 무료 IDE 편집기

스튜디오 13.0.1 보내기
강력한 PHP 통합 개발 환경

DVWA
DVWA(Damn Vulnerable Web App)는 매우 취약한 PHP/MySQL 웹 애플리케이션입니다. 주요 목표는 보안 전문가가 법적 환경에서 자신의 기술과 도구를 테스트하고, 웹 개발자가 웹 응용 프로그램 보안 프로세스를 더 잘 이해할 수 있도록 돕고, 교사/학생이 교실 환경 웹 응용 프로그램에서 가르치고 배울 수 있도록 돕는 것입니다. 보안. DVWA의 목표는 다양한 난이도의 간단하고 간단한 인터페이스를 통해 가장 일반적인 웹 취약점 중 일부를 연습하는 것입니다. 이 소프트웨어는
