GET
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://somewhere/?var=val");
//curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//不直接輸出
$result = curl_exec($ch);
curl_close($ch);
POST
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://somewhere/");
curl_setopt($ch, CURL_POST, true);
curl_setopt($ch, CURL_POSTFIELDS, http_build_query( array() ) );
//curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);//不直接輸出
$result = curl_exec($ch);
curl_close($ch);
沒有留言:
張貼留言