我在堆栈中从另一个问题复制了这段代码..
$fbid = '666666666';
$url = 'http://www.example.de/v/fffff.php'; // work
$url = 'http://www.example.de/v/fffff.php?fbid=' . $fbid; // not working, page don't load
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache"
),
));
$antwort = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
任何人都知道如何使用GET参数从url获取内容?
答案 0 :(得分:0)
您错过了将.
连接到网址的$fbid
。而且您还需要首先实例化curl
。将您的代码更改为:
$fbid = 123;// as sample dbid
$url = 'http://www.example.de/v/fffff.php'; // work
$url = 'http://www.example.de/v/fffff.php?fbid='.$fbid; // not working, page don't load
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => $url,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_HTTPHEADER => array(
"cache-control: no-cache"
),
));
$antwort = curl_exec($curl);
$err = curl_error($curl);
curl_close($curl);
希望这有帮助。