The code is simple:
<?php
function getStringFromUrl($url){
    $fResource = fopen($url, 'r');
    do {
        $data = fread($fResource, 8192);
        if (strlen($data) == 0) {
            break;
            }   
            $contents .= $data;
    } while(true);
    fclose ($fResource);
    $contents = mb_convert_encoding($contents,'utf-8','gbk');
    return $contents;
}
echo getStringFromUrl(urlencode('http://int.dpool.sina.com.cn/iplookup/iplookup.php?format=text&ip=119.97.23.59'));
echo file_get_contents('http://blog.sina.com.cn/rss/1400122351.xml');
Sometimes I can get content, sometimes not. I can't figure out why.
(EDIT:the error msg is :[function.fopen]: failed to open stream and [function.file-get-contents]: failed to open stream)
Of course the 2 URL above are available.
I have also 开发者_运维问答set the allow_url_fopen = On in php.ini.
First of all - you don't need to urlencode full url! Only GET parameters:
echo file_get_contents('http://int.dpool.sina.com.cn/iplookup/iplookup.php?'.http_build_query(array(
  'format' => 'text',
  'ip'     => '119.97.23.59'
)));
Second thing you should share with is error message (if any)
 
         
                                         
                                         
                                         
                                        ![Interactive visualization of a graph in python [closed]](https://www.devze.com/res/2023/04-10/09/92d32fe8c0d22fb96bd6f6e8b7d1f457.gif) 
                                         
                                         
                                         
                                         加载中,请稍侯......
 加载中,请稍侯......
      
精彩评论