2014-04-28 168 views
-1

我有一個頭重定向代碼如何做一個捲曲GET請求

Header (Location:"http://www.foo.com/x.php?name=".$name."&mob=".$mobNo); 

,但如何做使用捲曲一樣嗎?如何呼應迴應?請幫

回答

0

使用curl_exec方法來檢索它使用cURL。

<?php 
$ch = curl_init(); 

// set URL and other appropriate options 
curl_setopt($ch, CURLOPT_URL, "http://www.foo.com/x.php?name=".$name."&mob=".$mobNo); 
curl_setopt($ch, CURLOPT_HEADER, 0); 

// Retrieve it 
curl_exec($ch); 
curl_close($ch); 
1

http://codular.com/curl-with-php

下面是關於如何使用捲曲和PHP

<?php 
    $c = curl_init(); 
    curl_setopt($c, CURLOPT_URL, 'http//whateverUrl.com'); 
or 
    $c = curl_init('http//whateverUrl.com'); 


    $response = curl_exec($c); 
    curl_close($c); 

?> 
1

就這樣一個教程:

$curl = curl_init(); 

curl_setopt_array($curl, array(
    CURLOPT_RETURNTRANSFER => 1, 
    CURLOPT_HEADER => 0, 
    CURLOPT_URL => sprintf('http://www.foo.com/x.php?name=%s&mob=%s', $name, $mobNo), 
)); 

$response = curl_exec($curl); 

curl_close($curl); 

echo $response;