今天开发企业号遇见了一个问题
用curl给服务器传递数据时候,要使用raw的格式,开始使用的是包culr/curl,一直无法实现,应该是哪里参数设置的不对。
后来改成如下的,就跑通了
$aa = json_encode(['user_ticket'=>$user_ticket]); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'https://qyapi.weixin.qq.com/cgi-bin/user/getuserdetail?access_token=' . $access_token ); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt($ch, CURLOPT_POST, 1 ); curl_setopt($ch, CURLOPT_POSTFIELDS, $aa ); curl_setopt($ch, CURLOPT_HTTPHEADER,array('Content-Type: text/plain')); $result=curl_exec ($ch); $resultArr = json_decode($result,true); if(json_last_error()!==JSON_ERROR_NONE){ echo '获取用户信息错误'.json_last_error(); exit(); }