2014-03-27 13 views
0

我有一個http GET方法url;轉到一個URL,但沒有真正這樣做

http://test.com/test.php?name=sam&age=20 

現在,我在不同的網站,我想打電話,或者說URL,使「得」的內容,而無需實際開始重定向到該URL被推平。

是否有一個函數或方法在PHP中來完成它?

+3

爲什麼要用'GET'如果你不想得到什麼? – gpgekko

+0

你的意思是從這個url http://test.com/test.php?name = sam&age = 20'獲取數據到另一個url? –

+2

你是否在談論像[AJAX](http://en.wikipedia.org/wiki/Ajax_%28programming%29)這樣的背景請求? – freefaller

回答

2

cURL reference

例如,

$urlStringData = "http://test.com/test.php?name=sam&age=20"; 

    $ch = curl_init(); 

    curl_setopt($ch, CURLOPT_HEADER, 0); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); //Set curl to return the data instead of printing it to the browser. 
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT,10); # timeout after 10 seconds, you can increase it 
    curl_setopt($ch, CURLOPT_USERAGENT , "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 6.1)"); 
    curl_setopt($ch, CURLOPT_URL, $urlStringData); #set the url and get string together 

    $return = curl_exec($ch); 
    curl_close($ch); 
+1

cURL方法工作:D – Isuru

+1

偉大的@isuru,快樂的編碼! –

相關問題