利用curl发送post请求完成数据,接口的访问,这里面的参数可以修正一下,就可以写成可以支持文件上传的一个post请求,但是我这里不做仔细的写了.等以后有时间了在考虑怎么分解这个方法:
function request_by_curl($remote_server, $post_string) {
$ch = curl_init ();
curl_setopt ( $ch, CURLOPT_URL, $remote_server );
curl_setopt ( $ch, CURLOPT_POSTFIELDS, $post_string );
curl_setopt ( $ch, CURLOPT_RETURNTRANSFER, true );
curl_setopt ( $ch, CURLOPT_USERAGENT, "snsgou.com's CURL Example beta");
$data = curl_exec ( $ch );
curl_close ( $ch );
return $data;
}