Why i Canot make curl of this url?

9 replies
////////////////// i has try to use file_get_conetents////////
<?
$test = "http://220.181.23.202/s1/rpxiBVe6lybzimWQ/cdceabe1e4f1f901fb677c2ce64fb950/1246778125/v4/2006/mv/200750/11719752251z5ok.flv?ref=out";

$res = file_get_contents($test);

echo $res;
?>
//////////////////// and i use curl here ////////////////////

<?

function get($url1){
if(!isset($timeout))
$timeout=30;
$curl = curl_init();
if(strstr($referer,"://")){
curl_setopt ($curl, CURLOPT_REFERER, $referer);
}
curl_setopt ($curl, CURLOPT_URL, $url1);
curl_setopt ($curl, CURLOPT_TIMEOUT, $timeout);
curl_setopt ($curl, CURLOPT_USERAGENT, sprintf("Mozilla/%d.0",rand(4,5)));
curl_setopt ($curl, CURLOPT_HEADER, (int)$header);
curl_setopt ($curl, CURLOPT_RETURNTRANSFER, 1);
curl_setopt ($curl, CURLOPT_SSL_VERIFYPEER, 0);

$res = curl_exec($curl);

curl_close($curl);
return $res;
}

$test = "http://220.181.23.202/s1/rpxiBVe6lybzimWQ/cdceabe1e4f1f901fb677c2ce64fb950/1246778125/v4/2006/mv/200750/11719752251z5ok.flv?ref=out";

$content = get($test);
echo $content;
?>
////////////////////////////and i use fopen////////////////////

<?
$test = "http://220.181.23.202/s1/rpxiBVe6lybzimWQ/cdceabe1e4f1f901fb677c2ce64fb950/1246778125/v4/2006/mv/200750/11719752251z5ok.flv?ref=out";


$handle = fopen("$test", "rb");
$contents = '';
while (!feof($handle)) {
$contents .= fread($handle, 8192);
}
fclose($handle);


echo $contents;


?>
please can someone tell me what must i do to grab the contents
#canot #curl #make #url
  • Profile picture of the author dvduval
    Have you checked with your host to make sure they allow curl of external urls?
    Signature
    It is okay to contact me! I have been developing software since 1999, creating many popular products like phpLD.
    {{ DiscussionBoard.errors[946192].message }}
  • Profile picture of the author GB2008
    That was my first thought too - my host caught me on this - especially on a shared hosting plan, they often block outgoing connections from your server. Blocks RSS feed reading scripts, CURL - anything like that. Check with them first - they can usually create an exception for just your script to connect out.
    Signature
    {{ DiscussionBoard.errors[946397].message }}
    • Profile picture of the author hotscode
      Originally Posted by GB2008 View Post

      That was my first thought too - my host caught me on this - especially on a shared hosting plan, they often block outgoing connections from your server. Blocks RSS feed reading scripts, CURL - anything like that. Check with them first - they can usually create an exception for just your script to connect out.
      thanks for reply.

      your right . my host blocking curl from that url . what can i do for get the content. can i use proxy.
      {{ DiscussionBoard.errors[948414].message }}
  • Profile picture of the author GB2008
    Sounds a bit strange that they're blocking just that one url unless the server is on a blacklist - usually they block ALL external URLs and then they can enable just the ones that you need to access. My point being that a proxy probably won't help you in this case - you need to get your host to enable external access for this script or, if they won't, find another host!

    For what it's worth - I've used Aplus.net for my hosting and had no problems getting ports and external URLs enabled - it's a bit of a pain having to go through the process at all, but if it keeps my shared host safe - no problem!
    Signature
    {{ DiscussionBoard.errors[948977].message }}
  • Profile picture of the author hotscode
    you are right gb208 i got another curl problem . when i ask justhost.com they said the said dalas data center has blocking the url .
    {{ DiscussionBoard.errors[959381].message }}
  • Profile picture of the author eddiejames
    If the data centre is blocking the URL, I would be very suspicious of having anything to do with that!

    Is it some kind or illegal or unwanted content? Be careful... Chances are, if the providers data center is blocking the URL, the content will not be welcome on a server within their network anyway.
    {{ DiscussionBoard.errors[960393].message }}
  • Profile picture of the author hotscode
    ohh thanks for the information eddiejames.
    {{ DiscussionBoard.errors[960484].message }}
  • Profile picture of the author GB2008
    Don't get too carried away with that being a bad URL just based on this information - in my experience, web hosts block ALL external URL access by default to be on the safe side - good and bad URLs. Try googling the URL you are after, or maybe googling URL blacklists to see if it shows on them and get another opinion before you label it bad.

    My feeling is that you just need to have the data center enable connections from your script to the URL(s) you want - they should be able to do that, if their company policy allows for it.
    Signature
    {{ DiscussionBoard.errors[960700].message }}
  • Profile picture of the author hotscode
    thank gb2008 for trying to help me .
    {{ DiscussionBoard.errors[964385].message }}

Trending Topics