第三方平台配置小程序域名


第三方平台小程序配置域名,包括:

requestdomain
wsrequestdomain
uploaddomain
downloaddomain

Api接口:

https://api.weixin.qq.com/wxa/modify_domain?access_token=?
$authorizerAccessToken = $this->getTokenByAppid($appid);//通過小程序的appid拿到accessToken
//授權成功后設置小程序的4個域名
$postArray = array();
$postArray["action"] = "set";//有add、set,一般用set
$postArray["requestdomain"] = XXXXXX;
$postArray["wsrequestdomain"] = XXXXX;
$postArray["uploaddomain"] = XXXXX;
$postArray["downloaddomain"] = XXXXX;
Logger::info(json_encode($postArray)); 

$url = "https://api.weixin.qq.com/wxa/modify_domain?access_token=".$authorizerAccessToken;

$postresArray = json_decode(HttpRequest::POSTJSON($url, json_encode($postArray)), true); //這里是發請求
Logger
::info('設置域名結果'.json_encode($postresArray));

注意:

1、設置的小程序域名必須加到第三方平台的 “小程序服務器域名” 里面,這里可以理解成白名單,不是這里面填寫的域名配置不上去的

2、設置的域名必須以 “https” 開頭

3、AccessToken盡量用最新的

 

附:拿到最新的AccessToken代碼

$postArray = array();
$postArray["component_appid"] = XXXXXX;//第三方平台的appid
$postArray["authorizer_appid"] = XXXXXX;//小程序的appid
$postArray["authorizer_refresh_token"] = XXXXXX;//小程序授權給第三方平台之后的憑證
$url = "https://api.weixin.qq.com/cgi-bin/component/api_authorizer_token?component_access_token=?";
$postresArray = json_decode(HttpRequest::POSTJSON($url, json_encode($postArray)),true);
Logger::info('minitoken,'.$id.','.json_encode($postresArray));

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM