[php]通过http post发送json数据
2014-03-31 23:23
645 查看
function http_post_data($url, $data_string) { $ch = curl_init(); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Content-Type: application/json; charset=utf-8', 'Content-Length: ' . strlen($data_string)) ); ob_start(); curl_exec($ch); $return_content = ob_get_contents(); ob_end_clean(); $return_code = curl_getinfo($ch, CURLINFO_HTTP_CODE); return array($return_code, $return_content); } $url = "http://xx.xx.cn"; $data = json_encode(array('a'=>1, 'b'=>2)); list($return_code, $return_content) = http_post_data($url, $data);
相关文章推荐
- PHP通过Http Post请求发送Json对象数据?
- PHP如何通过Http Post请求发送Json对象数据?
- [php]通过http post发送json数据
- [php]通过http post发送json数据
- [php]通过http post发送json数据
- PHP如何通过Http Post请求发送Json对象数据?
- [php]通过http post发送json数据
- php通过curl post和get发送json数据实例 curl命令转为php源码
- okhttp通过post发送Json数据到php 更新数据库
- iOS通过ASIHttpRequest接收php端发送的Json数据
- 通过http post发送json数据
- HttpClient通过Post方式发送Json数据
- php 通过curl post发送json数据实例
- iOS通过ASIHttpRequest接收php端发送的Json数据
- HttpClient通过Post方式发送Json数据
- iOS通过ASIHttpRequest接收php端发送的Json数据
- iOS通过ASIHttpRequest接收php端发送的Json数据
- [置顶] HttpClient通过Post方式发送Json数据
- PHP后端接收不到AngularJs中$http.post发送的数据的问题
- php获取通过http协议post提交过来xml数据及解析xml