Home > Backend Development > PHP Tutorial > 如何获取微信开放平台的预授权码?

如何获取微信开放平台的预授权码?

WBOY
Release: 2016-06-06 20:34:13
Original
2602 people have browsed it

怎样获取微信开放平台的预授权码?是通过填写的哪个url进入获取的?

报错:

<code>array(2) { ["errcode"]=> int(41002) ["errmsg"]=> string(13) "appid missing" } 
</code>
Copy after login
Copy after login

代码部分:

<code>    $ch = curl_init();
    $url="https://api.weixin.qq.com/cgi-bin/component/api_component_token";
    $data=array(
        'component_appid'=>$APPID,
        'component_appsecret'=>$SECRET,
        'component_verify_ticket'=>$ticket['ticket']
    );
    $data=http_build_query($data);
    //var_dump($data);

    $ch = curl_init();//打开
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    $response  = curl_exec($ch);
    curl_close($ch);//关闭
    $result = json_decode($response,true);
</code>
Copy after login
Copy after login

回复内容:

怎样获取微信开放平台的预授权码?是通过填写的哪个url进入获取的?

报错:

<code>array(2) { ["errcode"]=> int(41002) ["errmsg"]=> string(13) "appid missing" } 
</code>
Copy after login
Copy after login

代码部分:

<code>    $ch = curl_init();
    $url="https://api.weixin.qq.com/cgi-bin/component/api_component_token";
    $data=array(
        'component_appid'=>$APPID,
        'component_appsecret'=>$SECRET,
        'component_verify_ticket'=>$ticket['ticket']
    );
    $data=http_build_query($data);
    //var_dump($data);

    $ch = curl_init();//打开
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    $response  = curl_exec($ch);
    curl_close($ch);//关闭
    $result = json_decode($response,true);
</code>
Copy after login
Copy after login

appid missing
你没有定义$APPID变量

是$data传值的问题,已经解决了

遇到同样问题,传参的时候是json格式 之前直接post 3个参数一直{"errcode":41002,"errmsg":"appid missing"} 这个错误。json_encode(['component_appid'=>,'component_appsecret'=>,'component_verify_ticket'=>]);

$data 要以JSON格式提交

Related labels:
php
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template