>[info] 接口:http://127.0.0.1:2945 ``` // api 聊天demo public function apiChat() { // apiService 得到的客服信息 $kefuInfo = [ 'data' => [ 'kefu_code' => 'KF_5c6ce9f6d753b', 'kefu_name' => '客服小白', 'seller_code' => '5c6cbcb7d55ca' ] ]; $push_api_url = "http://127.0.0.1:2945"; $post_data = [ "cmd" => "c2sChat", "data" => [ 'from_name' => "访客20190321", 'from_avatar' => "//tva2.sinaimg.cn/crop.0.0.512.512.180/005LMAegjw8f2bp9qg4mrj30e80e8dg5.jpg", 'from_id' => 20190321, 'content' => 'api聊天测试', 'to_id' => $kefuInfo['data']['kefu_code'], 'to_name' => $kefuInfo['data']['kefu_name'], 'seller_code' => $kefuInfo['data']['seller_code'] ] ]; $ch = curl_init (); curl_setopt ( $ch, CURLOPT_URL, $push_api_url ); curl_setopt ( $ch, CURLOPT_POST, 1 ); curl_setopt ( $ch, CURLOPT_HEADER, 0 ); curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, 1 ); curl_setopt ( $ch, CURLOPT_POSTFIELDS, http_build_query($post_data)); $return = curl_exec ( $ch ); curl_close ( $ch ); echo $return; } ``` 返回信息是一段 json ``` {code: 200, data: '', msg: 'ok'} ```