[php]通过http post发送json数据
2012-09-24 22:43
806 查看
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数据
- HttpClient通过Post方式发送Json数据
- iOS通过ASIHttpRequest接收php端发送的Json数据
- iOS通过ASIHttpRequest接收php端发送的Json数据
- [置顶] HttpClient通过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数据
- c++ HTTP POST请求 向服务器发送json数据
- Android系列之网络(三)----使用HttpClient发送HTTP请求(分别通过GET和POST方法发送数据)