2

工作代码

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "http://###.#####.###/####/####/T0103/templateCustomWebPage.do?webId=1209221452326&editCurrentLanguage=1209221452328&customWebPageId=1292822288140001019");
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
curl_close($ch);
echo $data;[/code]

但如果我使用数据库中的 url 而不是它不起作用。

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $r->url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
curl_close($ch);
echo $data;

将显示以下错误...

parameter is wrong ,please check your input url.
Your input URL:
http://###.#####.###/####/####/T0103/templateCustomWebPage.do?webId=1209221452326&editCurrentLanguage=1209221452328&customWebPageId=1292822288140001019

先感谢您!

4

1 回答 1

5

您的 url 与 html 实体一起存储在数据库中。CURL 调用不接受这些。

试试这个:

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, html_entity_decode($r->url));
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
$data = curl_exec($ch);
curl_close($ch);
echo $data;

我添加了html_entity_decode http://php.net/manual/en/function.html-entity-decode.php

于 2013-03-07T08:45:20.190 回答