第三方微信小程序服务器地址设置

前端之家收集整理的这篇文章主要介绍了第三方微信小程序服务器地址设置前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

第三方微信小程序服务器地址设置

需要先将域名登记到第三方平台的小程序服务器域名中,这个的意思就是添加的域名必须在第三方平台配置的域名。

微信小程序服务器地址设置" alt="第三方微信小程序服务器地址设置">

PHP代码

$url = 'https://api.weixin.qq.com/wxa/modify_domain?access_token='.$acctoken;
$post['action'] = 'set';
$post['requestdomain'] = ['https://aa.com'];
$post['wsrequestdomain'] = ['wss://aa.com','wss://ws.im.jiguang.cn'];
$post['uploaddomain'] = ['https://aa.com','https://sdk.im.jiguang.cn'];
$post['downloaddomain'] = ['https://aa.com','https://sdk.im.jiguang.cn'];
$data = wxPostCurl( $url, $post );

/**
 
 @param $url
  @param $dataObj
 
 @return mixed
  微信接口 curl post请求
 
/
function wxPostCurl( $url , $dataObj )
{
    //初使化init方法
    $ch = curl_init();
    //指定URL
    curl_setopt($ch, CURLOPT_URL, $url);
    //设定请求后返回结果
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    //声明使用POST方式来进行发送
    curl_setopt($ch, CURLOPT_POST, 1);
    //发送什么数据呢
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($dataObj,JSON_UNESCAPED_UNICODE));
    //忽略证书
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
    //忽略header头信息
    curl_setopt($ch, CURLOPT_HEADER, 0);
    //设置超时时间
    curl_setopt($ch, CURLOPT_TIMEOUT, 10);
    //发送请求
    $output = curl_exec($ch);
    //关闭curl
    curl_close($ch);
    //返回数据
    return $output;
}


原文链接:https://www.f2er.com/weapp/422930.html

猜你在找的微信小程序相关文章