Pedro Chagas
asked on
Beginning with PEAR Services_google
Hi, First I have to tell, in API services I don't have any knowledge.
I work well with other scripts of PEAR, like language detect and some others, but Services Google is more difficulty because is involve other identity or other site, in this case google.
I have now a API key, I get from maps (I think with one key I can get to the others API's).
I Have interest in special by 'spelling suggestions' of Service_Google!
Like I tell above, I don't have any experience in google API's, I copy the code you can see in code snippet and I do some little changes, like put my key inside $key.
So, if I want to use 'spelling suggestions' the code in code snippet is the correct? I don't think so, and I don't have any idea what that script do! And when I try in my server I get this #error:
Fatal error: Call to a member function search() on a non-object in /home/tags/public_html/bas tidores/te ste.php on line 47.
Who give me a help to working with spelling suggestions or Services_Google (PEAR)?
Regards,
JC
I work well with other scripts of PEAR, like language detect and some others, but Services Google is more difficulty because is involve other identity or other site, in this case google.
I have now a API key, I get from maps (I think with one key I can get to the others API's).
I Have interest in special by 'spelling suggestions' of Service_Google!
Like I tell above, I don't have any experience in google API's, I copy the code you can see in code snippet and I do some little changes, like put my key inside $key.
So, if I want to use 'spelling suggestions' the code in code snippet is the correct? I don't think so, and I don't have any idea what that script do! And when I try in my server I get this #error:
Fatal error: Call to a member function search() on a non-object in /home/tags/public_html/bas
Who give me a help to working with spelling suggestions or Services_Google (PEAR)?
Regards,
JC
$key = "//my key that I get in google API maps";
require_once '/home/tags/php/Services/Google.php';
$google->search("PEAR"); //line 47 line 47 line 47
foreach($google as $key => $result) {
echo $key."\t".$result->title."\n";
}
ASKER
I tell my knowledge in API is not to much, so I don't understand the new line 1: $google = new OOP-THING;
What I write to replace the word OOP-THING?
I do that changes in the code, I replace $google->search("PEAR"); for $google = new OOP-THING; and I get this error: Fatal error: Class 'OOP' not found in /home/tags/public_html/bas tidores/te ste.php on line 47
Can you be more precise.
Regards,
JC
What I write to replace the word OOP-THING?
I do that changes in the code, I replace $google->search("PEAR"); for $google = new OOP-THING; and I get this error: Fatal error: Class 'OOP' not found in /home/tags/public_html/bas
Can you be more precise.
Regards,
JC
$key = "MY KEY";
require_once '/home/tags/php/Services/Google.php';
$google = new OOP-THING; //line 47 line 47 line 47
foreach($google as $key => $result) {
echo $key."\t".$result->title."\n";
}
You need to initiate the class like Ray_Paseur suggested.
This is the way: $google = new Services_Google($key);
or if this doesn't work open file Google.php in notepad or your editor and search for class name and replace it with above `Services_Google`. The final code should look like below code. Also to learn more about OOP go here: http://serialize.us/?page_ id=92
This is the way: $google = new Services_Google($key);
or if this doesn't work open file Google.php in notepad or your editor and search for class name and replace it with above `Services_Google`. The final code should look like below code. Also to learn more about OOP go here: http://serialize.us/?page_
$key = "//my key that I get in google API maps";
require_once '/home/tags/php/Services/Google.php';
$google = new Services_Google($key);
$google->search("PEAR"); //line 47 line 47 line 47
foreach($google as $key => $result) {
echo $key."\t".$result->title."\n";
}
ASKER
With the new code, I don't get any error, but I don't get anything, appear a blank page.
I go to http://serialize.us/?page_id=92, like you tell me, I read, but the examples is just to get names of books, and I want work with 'spelling suggestions'.
After I have this code, what I have to do?
$key = "//my key that I get in google API maps";
require_once '/home/tags/php/Services/G oogle.php' ;
$google = new Services_Google($key);
$google->search("PEAR"); //line 47 line 47 line 47
foreach($google as $key => $result) {
echo $key."\t".$result->title." \n";
}
Give me just a little example, after I get a little example maybe I understand more difficulty things.
Regards,
JC
I go to http://serialize.us/?page_id=92, like you tell me, I read, but the examples is just to get names of books, and I want work with 'spelling suggestions'.
After I have this code, what I have to do?
$key = "//my key that I get in google API maps";
require_once '/home/tags/php/Services/G
$google = new Services_Google($key);
$google->search("PEAR"); //line 47 line 47 line 47
foreach($google as $key => $result) {
echo $key."\t".$result->title."
}
Give me just a little example, after I get a little example maybe I understand more difficulty things.
Regards,
JC
ASKER
I check the file Google.php of PEAR in my server, and I found the function that made what I want about 'spelling suggestions'. I copy the function:
========================== =====
/**
* Does a spell check using Google's spell checking engine.
*
* @param string $phrase The string to spell check.
* @return string A suggestion of how the phrase should be spelt.
* @access public
*/
public function spellingSuggestion($phrase )
{
return $this->_soapClient->doSpel lingSugges tion($this ->key, $phrase);
}
========================== ========== ===
If I have a phrase or string like $string = "the planet is round"; how I use the string in function above?
Don't forget, I have this code:
$key = "//my key that I get in google API maps";
require_once '/home/tags/php/Services/G oogle.php' ;
$google = new Services_Google($key);
$google->search("PEAR"); //line 47 line 47 line 47
foreach($google as $key => $result) {
echo $key."\t".$result->title." \n";
}
Please tell me how I use the function spellingSuggestion?
Regards, JC
==========================
/**
* Does a spell check using Google's spell checking engine.
*
* @param string $phrase The string to spell check.
* @return string A suggestion of how the phrase should be spelt.
* @access public
*/
public function spellingSuggestion($phrase
{
return $this->_soapClient->doSpel
}
==========================
If I have a phrase or string like $string = "the planet is round"; how I use the string in function above?
Don't forget, I have this code:
$key = "//my key that I get in google API maps";
require_once '/home/tags/php/Services/G
$google = new Services_Google($key);
$google->search("PEAR"); //line 47 line 47 line 47
foreach($google as $key => $result) {
echo $key."\t".$result->title."
}
Please tell me how I use the function spellingSuggestion?
Regards, JC
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
About the code of 'al3cs12', I thing is work. But now I have a problem of invalid key, and the system when I ruyn the script give me this message:
========================== ========== ===
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Invalid key: ABQIAAAAqfY-BfCgaVIYFbuvkK MFNBQUy4sC 81vI6rN4yO TiPQw_uMNI 8hTIerz3C- GAZJMFL61u R51YZNBCCw in /home/tags/php/Services/Go ogle.php:2 11 Stack trace: #0 [internal function]: SoapClient->__call('doSpel lingSugge. ..', Array) #1 /home/tags/php/Services/Go ogle.php(2 11): SoapClient->doSpellingSugg estion('AB QIAAAAqfY- BfC...', 'the planet is r...') #2 /home/tags/public_html/bas tidores/te ste.php(18 ): Services_Google->spellingS uggestion( 'the planet is r...') #3 {main} thrown in /home/tags/php/Services/Go ogle.php on line 211
========================== ========== ===
I get that key from map API, but like you see, that key don't work in spelling suggestion.
Where is the righ place or API to get a key for my script?
Thanks to 'al3cs12' by code!
Regards, JC
==========================
Fatal error: Uncaught SoapFault exception: [SOAP-ENV:Client] Invalid key: ABQIAAAAqfY-BfCgaVIYFbuvkK
==========================
I get that key from map API, but like you see, that key don't work in spelling suggestion.
Where is the righ place or API to get a key for my script?
Thanks to 'al3cs12' by code!
Regards, JC
the php code is working but you should get a valid key from google API, i'm not familiar with this but you should check out http://code.google.com/int l/en/, and if any new problems arrise you can open a new questions. Good luck
Open in new window