Google API + SOAP

Any other programming language that is not covered in the Web Scripting category.

Google API + SOAP

Postby chiron on Fri May 26, 2006 6:18 pm

Im having trouble using the Google API and PHP i keep getting 502 errors, about every 9 out of 10 times. Do you think it could be a bad version of SOAP, im using PEAR::SOAP v0.9.4. Here's the script

Code: Select all
<?php

    $soap = new SOAP_Client('http://api.google.com/search/beta2');

    $params = array(
                'key' => 'xlbreL9QFHJQC8CRfdREEIsNbyoIPgeo',
                'q' => 'query',
                'start' => 0,
                'maxResults' => 1,
                'filter' => false,
                'restrict' => '',
                'safeSearch' => false,
                'lr' => '',
                'ie' => '',
                'oe' => ''
        );

    $results = $soap->call('doGoogleSearch', $params, 'urn:GoogleSearch');

    if (PEAR::isError($results)) {
        print "Error: " . $results->getCode() . "<br>";
        print $results->getMessage();
    } else  {

   $url = $ret->resultElements[0]->URL;
   $title = $ret->resultElements[0]->title;
   $title = preg_replace('@<[\/\!]*?[^<>]*?>@si', '', $title);
   $title = preg_replace('@<[\/\!]*?[^<>]*?@si', '', $title);
   print $title . " - " . $url;
       

    }

?>
chiron
Newbie
Newbie
 
Posts: 9
Joined: Fri May 26, 2006 5:01 pm
Location: England

Return to Programming

Who is online

Users browsing this forum: No registered users and 1 guest

cron