Search Google Shopping products PHP - php

Is it possible, using Google's API or merely faking a request to retrieve the products from a google shopping search query ? For example :
https://www.google.de/#tbm=shop&q=Samsung+Galaxy
I would like to retrieve all the results for the following query, trying to fake a request resulted me in an empty page as it seems like it makes a weird AJAX request to Google's API which I cannot parse.
Is there something similar to
http://ajax.googleapis.com/ajax/services/search/web?v=1.0&q=Samsung+Galaxy
for example ?

After doing a wide research I've seen that there is no API for google shopping - they closed it a while ago.
Therefore I used PhantomJS to render the whole page and then retrieve the data.

Related

Google Analytics PHP API : get reporting

I have a professional website using Google Analytics for metrics and I try to automatize one task I used to do manually but.. not able to understand if it's possible ?!
I just began to using the Google PHP client library to access the Google Analytics API on my website Test with the HelloAnalytics.php file is OK, I manage to connect and retrieve my data.
What i'm trying to do is :
Get all URLs viewed in the past 24H (what you can see when you navigate in the GA dashboard -> Behavior -> Site content -> All pages)
Combine those datas with my custom Definition which is in fact a special token i generate for every users on my website via PHP, then send it thought with Javascript and ga('set', 'mycustomdefinition', 'my token');
Is it possible ?
Many thanks in advance for your support !
Data under 24-48 hours old has probably not completed processing so I recommend not looking at data viewed in the last 24 hours it wont be correct. Other wise yes you can see this.
Assuming you mean custom Dimension yes you can extract custom dimensions and the page path in the same request.
You might want to have a look at the Dimensions & metrics explorer as well as the google analytics query explorer both will help you understand what data can be extracted from the API.

YouTube api v3 get video category

I'm working on a migration of the v2 implementation to v3, but I'm having some difficulty understanding how is API v3 segmented. I'm trying to get the video details from the API but for example, I'm unable to find where the video Category name is stored.
In the v2 implemetation I have:
$title = $info->entry->title->{'$t'};
$content = nl2br($info->entry->{'media$group'}->{'media$description'}->{'$t'});
and also
$info->entry->category
How would I translate this to the v3 implementation?
currently the api (v2) is quering this:
http://gdata.youtube.com/feeds/api/videos/
What is the v3 equivalent?
This is a PHP implementation btw.
thanks in advance
In V3, you don't query feeds, but instead query RESTful endpoints. So in your case, if you already know the videoIDs of the videos you want, you'll hit the videos->list endpoint, like this:
https://www.googleapis.com/youtube/v3/videos?part=snippet&id={comma separated list of video IDs}&key={YOUR_API_KEY}
The resultant json packet will have an 'items' list; each 'item' has a 'categoryId'.
Note that, to get details about the category ID itself, you can use the videoCategories->list endpoint, like this:
https://www.googleapis.com/youtube/v3/videoCategories?part=snippet&id={comma separated list of ids}&key={YOUR_API_KEY}
The categories don't change all that often, so you can likely cache a lot of this data, but it is sometimes helpful to have your app keep up on the category details as that API also returns things like the auto-generated channel ID for the category, localized info (what the title of the category is in other languages and other regions), etc.
If you DON'T already have the videoIDs, you cannot use the videos->list endpoint, but instead must use the search->list endpoint. This gives you access to use lots of parameters to filter your search ... all are described here:
https://developers.google.com/youtube/v3/docs/search/list
The problem with this, however, is that the results of the search endpoint do NOT give you the categoryID, so currently you'd have to aggregate all the videoIDs from your search result and do a call to the videos->list endpoint with those ids to get the categories.

Automatic php script to know how many view have your page with Google Analytics

I want to know the number of view of my web page using a script php that query Google Analytic.
I know that there is the Google API, but there is a bad documentation of it.
You know how do that?
are you looking for a simple script that just saves the number of a page view in the database and later you could get the value , or you want to get the number of page view calculated with the google Analytic api ? in that case , you're talking about building a Rest Api (Interact with the google server) and you should read about the google APi .

Posting Data to Amazon using curl

when we enter a keyword (search term) in amazon kindle book store, search brings a list of books back.
I am trying to scrap the above said amazon kindle book search, i have some basic/usage idea of CURL in php, but i have never posted variables using curl. I tried at my level. but havent succeeded yet. the only thing i know is i should post "key-word" variable to amazon and should grab the result.
The problem with this step is that the key-word is submited to the form and only a part of the page is refreshed everytime key-word is entered.
can somebody help me telling the step required?
which data i will need to post icluding key-word? how can i know about
the header /user agent required for this? what information will be required for this process? which elements will be posted ?
I have tried using fiddler but as i am new to it, i am not getting the concepts.
The link i want to parse is amazon.com
Guideline please, if i get the what needs to be posted, i think i will be able to do the curl process.

Google Custom Search Engine (CSE) API

I am trying to integrate a site search feature into a client's site. I've created an test search engine with Google Custom Search, but I can't sort out how to make it work with the following criteria:
The search form posts back to the site
The POST page uses an API to get the result back from Google
I display the results within my site
Am I misunderstanding how Google Custom Search works? Is there a simple tutorial somewhere that fits my criteria?
Thanks!
Google Custom Search Business Edition specifically has the API to return XML results, with which you can do what you please. Business Edition is not free.
Here is the XML results documentation.
From PHP, you can use cURL to pass your POSTed search query on to Google CSE as a GET request, and then do whatever you want with the XML server side or client side.
Check out http://www.google.com/cse/docs/resultsxml.html
But basically yeah: have a page on your site that when it gets a post/get variable it makes an http request to Google containing (at least) your search term and your api key, it then receives a load of XML in return which it then formats and returns on the page.
It's pretty straightforward. I've not implemented it in PHP, which judging by your tag is the lanaguage you're looking to do it in, but something like http://www.seopher.com/articles/google_custom_search_tutorial_using_xml_and_php_ should put you on the right track.

Categories