微信小程序直播创建直播间传数据方式,

浏览1363

image.png


$data['name']=$roomname;
$data['coverImg']='pJeJNYwWs7SyNXvILQCUzFIQ629hLn4aLNX-4kcVKvpOrIGFcBC3gI9FDeGEZqSf';//YnomuWvSpdsxD6e-2kLKSV8v81uMAz4IVI1mC1gdvs8EJ9Dlnxoi1Fp0S0UkuT4t
$data['shareImg']='pJeJNYwWs7SyNXvILQCUzFIQ629hLn4aLNX-4kcVKvpOrIGFcBC3gI9FDeGEZqSf';
$data['feedsImg']='pJeJNYwWs7SyNXvILQCUzFIQ629hLn4aLNX-4kcVKvpOrIGFcBC3gI9FDeGEZqSf';
$data['startTime']='1660912784';//strtotime($date1.' 20:00:00')
$data['endTime']='1660991984';
$data['anchorName']='12121';
$data['anchorWechat']='MingRenZhi9670';//$anchorWechat
$data['subAnchorWechat']='1111';//$subAnchorWechat
$data['createrWechat']='MingRenZhi9670';//$createrWechat
$data['isFeedsPublic']=0;//$isFeedsPublic
$data['type']=0;
$data['closeLike']=0;//是否关闭点赞 【0:开启,1:关闭】
$data['closeGoods']=0;//是否关闭货架 【0:开启,1:关闭】
$data['closeComment']=0;//是否关闭评论 【0:开启,1:关闭】
$data['closeReplay']=1;//是否关闭回放 【0:开启,1:关闭】
$data['closeShare']=0;//是否关闭分享 【0:开启,1:关闭】
$data['closeKf']=1;//是否关闭客服 【0:开启,1:关闭】


$res=https_request($url, http_build_query($data));

创建直播间时,微信接口有毛病,json数据再度拼接成字符串,需要用

http_build_query

拼接一下才能创建成功


还有个上传素材是传的form表单的内容,不用传json数据

image.png

//https://api.weixin.qq.com/cgi-bin/media/upload?access_token=ACCESS_TOKEN&type=TYPE
$appid=MINIAPP_APPID;$appsecret=MINIAPP_SECRET;
$access_token=miniapp_getAccessToken($appid,$appsecret);
$filetype=$file['type'];
$url="https://api.weixin.qq.com/cgi-bin/media/upload?access_token=$access_token&type=image";
if (class_exists('\CURLFile')) {
   $file_wx['media'] = new \CURLFile(realpath($re['path']));
} else {
   $file_wx['media'] = '@'.realpath($re['path']);
}
$res=JsonPost($url, $file_wx);
//log_resulttest('上传临时素材返回:'.$res);
$json=json_decode($res,true);
return $json;




  • 暂无任何回答