The first time I started with this issue i didn't even know where to start. So i asked a
question on SO - the answer helped me to get the right direction.
Now i solved this issue and want to share the solution in this post:
Short introduction
If you want to show your g+ posts on your website you have to use the
Google+ HTTP API (programming interface to g+).
You can retrieve all public posts with the API call
activities.list.
The HTTP Request to get the public posts looks like this:
As you can see you have to put just one thing inside the url:
- the userId of your g+ account (you can find this id in the url of your g+ "profile" site)
On this site you can try it:
https://developers.google.com/+/api/latest/activities/list
Just enter your userId and set the collection to "public". After clicking on "execute" you can see the request to the server and the response from the server.
To get a successful response from the server you have to
Authorizing your API request.
Every request that an application sends to google needs an "API Key".
How to get an API Key for the G+ API?
First you have to create a new project in the
Googles API Console:
Then you have to enable the "Google+ API" Service:
|
enable Google+ API Service |
| | | | | |
accept terms of use | | | | | |
|
your Google+ API Service is enabled |
After the previous steps you can find you API Key at the menu item "API Access":
|
your API Key |
Example:
Show Author, published date of post and the posts content on a php website:
- After unzipping the *.gz and than the *.tar file you should see the php client library "google-api-php-client"
- create a simple "index.php" (at the same folder where you find the php client library) where you want to show your posts, it can look like this:
- create a "show_posts.php" and copy the following code inside the file:
- Now it's done! Open your "index.php" in a webbrowser and you see all your posts!