Reputation:
working code
$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]
but if i use url from database than its not working.
$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;
following error will be display...
parameter is wrong ,please check your input url.
Your input URL:
http://###.#####.###/####/####/T0103/templateCustomWebPage.do?webId=1209221452326&editCurrentLanguage=1209221452328&customWebPageId=1292822288140001019
Thank you in advance!
Upvotes: 2
Views: 554
Reputation: 28732
Your url is stored with html entities in the database. The CURL call doesn't accept those.
Try this:
$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;
I've added html_entity_decode http://php.net/manual/en/function.html-entity-decode.php
Upvotes: 5