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

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

报错:

array(2) { ["errcode"]=> int(41002) ["errmsg"]=> string(13) "appid missing" } 

代码部分:

    $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);
阅读 9.7k
4 个回答

appid missing
你没有定义$APPID变量

新手上路,请多包涵

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

新手上路,请多包涵

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

新手上路,请多包涵

$data 要以JSON格式提交

撰写回答
你尚未登录,登录后可以
  • 和开发者交流问题的细节
  • 关注并接收问题和回答的更新提醒
  • 参与内容的编辑和改进,让解决方法与时俱进
推荐问题