SitePoint Sponsor

User Tag List

Results 1 to 7 of 7
  1. #1
    SitePoint Member edpudol's Avatar
    Join Date
    Oct 2004
    Location
    philippines
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    error on Display google PR

    I want to display Google PR using a ph code...

    here is my code
    $filename="http://www.google.com/search?client=navclient-auto&ch=6999123761&features=Rank&q=info: http://www.eservicesite.com";
    $file = fopen($filename, "r");
    First question is how can I display the result....

    but of course I got error opening the $filename variable, I got a
    fopen(http://www.google.com/search?client=...ervicesite.com
    ): failed to open stream: HTTP request failed! HTTP/1.0 403 Forbidden error what this mean?

    But when I copy and paste the code in my browser address bar it works.

    Any help? If some one could help me with this I will share the entire script

  2. #2
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    When posting PHP code, please use the php tags. It makes the code much easier to look at.

    Onto your question...

    try the following

    PHP Code:
    $url 'http://www.google.com/search' 
             
    '?client=navclient-auto' .
             
    '&ch=6999123761' .
             
    '&features=Rank' .
             
    '&q=info: http://www.eservicesite.com';

    $contents file($url); 
    $contents will now be an array, with each line held as an array element.
    You can then use a foreach loop to loop through the array and the some kind of regular expressing match (or string search) to find the data you are looing for.

    Hope this helps

  3. #3
    SitePoint Member edpudol's Avatar
    Join Date
    Oct 2004
    Location
    philippines
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the reminder..

    I tried the code but still won't work I get the following error:
    Warning: file(): php_network_getaddresses: getaddrinfo failed: Temporary failure in name resolution in /home/www/site.com/g.php on line 10

    Warning: file(http://www.google.com/search?client=...s=Rank&q=info: http://www.eservicesite.com): failed to open stream: Connection timed out in /home/www/site.com/g.php on line 10

  4. #4
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I have had similar problems with other sites that I ahve tried to open. However, trying a minut or so later seems to resolve the problem.

    Do you always get this error?

    You could try googlline for php_network_getaddresses and getaddrinfo

  5. #5
    SitePoint Member edpudol's Avatar
    Join Date
    Oct 2004
    Location
    philippines
    Posts
    1
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes I always encounter this kind of problem.. working now then later not working.. so did yu solve yours.

  6. #6
    SitePoint Wizard swdev's Avatar
    Join Date
    Oct 2004
    Location
    UK
    Posts
    1,053
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Nope - I haven't solved it. I just live with the errors, and re-run the applicaiton later. For me, the errors aren't critical.

  7. #7
    SitePoint Enthusiast
    Join Date
    Sep 2004
    Location
    Belguim
    Posts
    26
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You can try the file_get_contents function
    http://be2.php.net/file_get_contents


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •