Google Custom Search Engine (CSE) API - php

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.

Related

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 .

Get language of Instagram post through API?

I am using the following URL to scrape the popular images/videos from Instagram (using PHP).
https://api.instagram.com/v1/media/popular?client_id=CLIENT-ID
It returns a json object, but I do not see a value for "language". This is a problem because sometimes the captains are in arabic or something else and I need them to be English for my web app. Is there anyway to know the language of the post or will I have to use some language detecting function?
Checkout this for the source code, and this for a demo. You then just have to pass the captions in to detect the language. It checks for 52 languages. You can also use Google Translate's API.

Facebook search

I am new to facebook api. I want to search for a particular word on facebook. I have gone through the documentation at https://developers.facebook.com/docs/reference/api/. But I dont know how to construct the query in PHP.
Could any one please provide a sample code. Also how do I specify the count and page (like twitter)?
I am currently using the API provided by facebook. I saw that there are alternative API's but I would like to restrict the API to the official one
Facebook provides the search functionality which is like searching using the search inside facebook.com.
To read about it go to here: http://developers.facebook.com/docs/reference/api/#searching
Edit
As it states in that document:
When searching for public posts or posts on the user's News Feed, you
can page over the results by using the since, until and limit
parameters. since and until both accept a unix timestamp.
Also, just a bit above the "searching" section there's the "Paging" section, using both you can come up with:
https://graph.facebook.com/search?q=coffee&type=place&offset=X&limit=4
Which in terms of using the php sdk, is probably like: "search?q=coffee&type=place&offset=X&limit=4"

Integration with google search result

I want to build a system in which the user enters a website domain and a word, and the system shows in which place he is located.
How can I get the search result from Google? there is any way? I am working with PHP and JavaScript.
Google does not provide a public API for querying the ranking (PageRank) of a page.
You could perform the query yourself and check the results against the domain you're looking for, but unless you look only to the first pages, it becomes unfeasible.
As to how to perform Google searches programmatically, see the Custom Search API.

google analytics api in php website

I am creating a custom reporting website, where I want to show live data from google analytics and accordingly the data in my website will change. I want it to be automated and dynamic, like whenever the data changes in GA, i want it to be automatically changed in our website, which will be shown to our clients to show the performance of our websites.
I am guessing this can be achieved by some api calling from php, xml returned values and showing those data on our website along with images.
i would appreciate if anyone could give me more info on how to start working on this.
Google Analytics has an official API. They don't seem to have ready-made PHP examples, but the XML sources should be easy to query. Not sure how "live" GA's data is, though - it could be that it is not possible to do stuff live tracking of visitors.

Categories