小程序获取直播间ID入参格式对吗?47001是因为入参格式?
发布于 4 年前 作者 qinqiang 10614 次浏览 来自 问答

3 回复

很多同学遇到这个问题呀…

注意下$query的值,是json格式,不是查询字符串

正确格式:{start:0 , limit:10}

错误格式:start=0&limit=10

有帮助到点个赞哦。

    /**

 \* 发送post请求

 \* [@param](/user/param) string $url 请求地址

 \* [@param](/user/param) array $data\_string post键值对数据,用json\_encode格式

 \*/

    function http_post($url, $data_string) {

  $ch = curl\_init();

  curl\_setopt($ch, CURLOPT\_URL, $url);

  curl\_setopt($ch, CURLOPT\_RETURNTRANSFER, 1);

  curl\_setopt($ch, CURLOPT\_HTTPHEADER, array(

   'X-AjaxPro-Method:ShowList',

   'Content-Type: application/json; charset=utf-8',

   'Content-Length: ' . strlen($data\_string))

  );

  curl\_setopt($ch, CURLOPT\_POST, 1);

  curl\_setopt($ch, CURLOPT\_POSTFIELDS, $data\_string);

  $data = curl\_exec($ch);

  curl\_close($ch);

  return $data;

}

    $url = ‘http://api.weixin.qq.com/wxa/business/getliveinfo?access_token=’.$token;

$data=json_encode(array(

“start”=>0,

  “limit”=>10

    ));

echo  $result=http_post($url,$data);

/*亲测可以*/

回到顶部