html52.com
我爱小程序-开发者交流社区

[订阅消息]PHP调用subscribeMessage.send总是说参数有误!?

subscribeMessage.send

1.token肯定没问题

我传的参数

{"touser":"oyvjN4rgZq34T7Sg6Ix5nOaY9tsk","template_id":"YSrUVGtX6Z3fpx6sn7TpsGWM__NNk9XMGOZ48GxQiSM","data":"{\"amount1\":{\"value\":\"1.604114\"},\"time2\":{\"value\":\"10:10\"},\"thing3\":{\"value\":\"福利奖池\"},\"thing4\":{\"value\":\"奖励已发放,请查收\"}}"}

返回的结果

{"errcode":47003,"errmsg":"argument invalid! hint: [.WbrhA07958651] data.time2.value is emtpy"}


很多方法都试过了.都跑不通. 之前调用API支付或者生成二维码都可以.

求解决~

/**

 * @param $url

 * @param array $data

 * @return mixed

 * curl请求

 */

function curl_post($url, $data = array())

{

    $ch = curl_init();

    curl_setopt($ch, CURLOPT_URL, $url);

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);

    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

    // POST数据

    curl_setopt($ch, CURLOPT_POST, 1);

    // 把post的变量加上

    curl_setopt($ch, CURLOPT_POSTFIELDS, $data);

    $output = curl_exec($ch);

    curl_close($ch);

    return $output;

}

/**

 * 发送post请求

 * @param string $url 请求地址

 * @param array $post_data post键值对数据

 * @return string

 */

function send_post($url, $post_data, $header = 'Content-type:application/x-www-form-urlencoded')

{


    $postdata = http_build_query($post_data);

    $options = array(

        'https' => array(

            'method' => 'POST',

            'header' => $header,

            'content' => $postdata,

            'timeout' => 15 * 60 // 超时时间(单位:s)

        )

    );

    print_r($options);

    $context = stream_context_create($options);

    $result = file_get_contents($urlfalse$context);


    return $result;

}


评论 抢沙发

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址

真正的个人免签约支付接口

云免签H5支付