How get google search results url?
(I use Zend_Gdata_Gbase for get search google results and not DomDocument/htmlsimpleparser because its looks to me that Zend_Gdata_Gbase done specially for parsing google results.
if I wrong in my selection, please write.)
My function to get google search results for 'yahoo' or other query search string:
(the function get a feed that should have search result for word 'yahoo', but when i use prin_t($feed) I don't see url for each result)
<?php
function queryGoogleSearch($queryString='yahoo'){
$service = new Zend_Gdata_Gbase();
$query = $service->newSnippetQuery();
$query->setBq('['.$queryString.']');
$query->setOrderBy('modification_time');
$query->setSortOrder('descending');
$query->setMaxResults('4');
$feed = $service->getGbaseSnippetFeed($query);
return $feed;
}
print_r(queryGoogleSearch());
?>
I get 4 first url results (when I search manually in google):
www.yahoo.com, mail.yahoo.com, search.yahoo.com, maps.yahoo.com
But I can't find them when I print $feed variable.
Please what should i change or add inqueryGoogleSearch() function? (Or other better code)
Thanks
Are you trying to search google.com. Looks like that class is for Google Base, not google.com search engine. http://base.google.com/support/bin/answer.py?hl=en&answer=59260
You probably want this: http://code.google.com/apis/customsearch/v1/overview.html
They recently just changed this. The old google search API has now deprecated as of Nov 1st. Custom search is the new API.
Its pretty simple to use without Zend.
http://code.google.com/apis/customsearch/v1/using_rest.html#WorkingResults
There is a JSON decoder in PHP.
http://php.net/manual/en/function.json-decode.php
Hope that helps!
Related
I am new to Redissearch-php , i want performs query search on redis with redis search engine (php). i have tried example from this link : http://www.ethanhann.com/redisearch-php/searching/, but its always returning empty array,
Please find code example here,
$document = $bookIndex->makeDocument();
$document->title->setValue('How to be awesome.');
$document->author->setValue('Jack');
$document->price->setValue(9.99);
$document->stock->setValue(9);
$bookIndex->add($document);
return $bookIndex->search('How')->getCount();
Can someone tell me, what i am doing wrong here ?
I used the following code to get title and like count of youtube video:
$gdata_url = 'http://gdata.youtube.com/feeds/api/videos/'.$videoId.'?v=2&alt=jsonc';
$json_content = file_get_contents($gdata_url, 0, null, null);
But currently title of json response always contains https://youtube.com/devicesupport instead of actual title and json response does not contain viewCount.
Could you please advise how to solve the issue?
Youtube API v2 has been deprecated. You can find how to get video info with v3 here.
You use the part parameter to define what properties you want to retrieve. Snippet gives you most of the properties including title and statistics returns the like count. You can use "snippet,statistics" to get both with one call.
I need a way to display videos from a specific channel on a page using PHP.
I have authenticated my app and I can use some methods using the advanced API. I am using the official vimeo PHP library to connect.
Below is what I am trying to do and when I dump the array I do not get anything. I can get info back from using get videos from the entire account method.
require_once('/url/vimeo/vimeo.php');
$vimeo = new phpVimeo('number', 'number');
$vimeo->setToken('number','numbers');
$videos = $vimeo->call('vimeo.channels.getVideos', array('ACCOUNT' => 'NAME'));
If I put the channel name where ACCOUNT is I will get an invalid signature error.
Is it worth using something like simple HTML parser for PHP and doing it that or worth sticking with the advanced API?
I would highly advise using the advanced api. If you parse the html, it will break any time vimeo changes their channel pages. Additionally, channels have more than one layout
eg: vimeohq and nicetype
The second parameter of the "call" function should be any querystring parameters the api method requires.
In the case of "vimeo.channels.getVideos" you can provide
channel_id
user_id
page
per_page
summary_response
full_response.
To experiment with the getVideos method, you can use the playground.
So in the end, I believe you want the function to look like this..
$videos = $vimeo->call('vimeo.channels.getVideos', array('channel_id' => 'NAME'));
where NAME is either the channel id, or the channel name (the channel name matches the url slug, so for example "nicetype" not "nice type"
'm using GAPI version 1.3 I have added a custom variable in GA code like this:
**_gaq.push(['_setCustomVar', 1, 'Member', '<?php echo $member_id; ?>, 3]);**
And its working fine..
Now I need to fetch the data from GA: so my request to GA is like this:
**https://www.google.com/analytics/feeds/data?
ids=XXXXXXXXXXX&
dimensions=ga:customVarValue1,ga:pagePath&
metrics=ga:pageviews,ga:uniquePageviews,ga:bounces,ga:exits&
filters=ga:pagePath=#event_details.php;ga:customVarValue1=2004036442&
start-date=2011-04-20&
end-date=2011-05-04&
max-results=50**
I need to fetch data from GA where pagePath=#event_details.php AND ga:customVarValue1=2004036442
But this is not resulting anything...
When I changed the filters in the following why its resulting all the pagePath = event_details.php and its working fine.. filters=ga:pagePath=#event_details.php
But I need get the page path with the particular member ID that is why I used the condition as below: filters=ga:pagePath=#event_details.php;ga:customVarValue1=2004036442&
So any one have idea about this?? Please help..
After looking at the code you posted in Google Docs, I see your problem.
Try using this as your filter.
$filter = 'pagePath =# ' . $filter_text[$tab] . ' && customVarValue1 == 2004036442'
The function you are passing $filter to does a cleanup process that escapes any reserved characters with a backslash. Your customVariable is being sent with a slash at the end, which is why it's not returning any matches.
and thanks for reading.
My problem is that I'm trying to get a list of contacts belonging to a group in GData using Zend_Gdata_Query.
Using
$query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/default/full/?group=http://www.google.com/m8/feeds/groups/xxx...xxx/base/XXX');
$feed = $gdata->getFeed($query);
give me an "Unknown authorization header".
$query = new Zend_Gdata_Query('http://www.google.com/m8/feeds/contacts/default/full/');
$query->setParam('group', 'http://www.google.com/m8/feeds/groups/XXX...XXX/base/XXX');
$feed = $gdata->getFeed($query);
is the same.
Obviously without that parameter I get all the contacts.
I already tried the first method with the parameter in the URL with a modified Extension to CakePHP core HttpSocket and it was working. So I suppose the problem is with Zend stripping out parameters from the url but I had no luck looking at the libraries.
Thanks for any help.
$query->setParam('group', 'http://www.google.com/m8/feeds/groups/myemail%40gmail.com/base/xxxxxxxxxxxxxx');
xxxxxxxxxxxxxx = group ID
As above the max-results also works if you add it to the query string like so:
http://www.google.com/m8/feeds/contacts/default/full?max-results=1000
Note that even in the google documentation the only way of getting ALL results is by 'setting a high number' for the number of results returned. So you can never explicitly specify 'ALL'
I guess you are using 3-legged OAuth. Then you need to add next line before getFeed() called:
$gdata->getHttpClient()->setRequestScheme(Zend_Oauth::REQUEST_SCHEME_QUERYSTRING);
It will solve "Unknown authorization header" error.
For me using
$query->setParam('group', 'http://www.google.com/m8/feeds/groups/XXX...XXX/base/XXX');
returns another error: "Invalid value for group parameter: XXXXXXXXXX" and I still dunno how to fix it :(