Google Plus Integration

Last modified by Thomas Mortagne on 2021/03/18 11:28

cogShow how to use the Google+ API
TypeSnippet
Category
Developed by

Vincent Massol

Rating
0 Votes
LicenseGNU Lesser General Public License 2.1

Table of contents

Description

Shows how to use the Google+ API from within XWiki.

Example

Code ripped from Guillaume's Blog

List all Google+ posts from a user (you'll need to put your Google+ API Key):

{{groovy}}
import groovy.json.*
import java.text.SimpleDateFormat

def sdf = new SimpleDateFormat("yyyy-MM-dd")

// my top secret API key
def myKey = "..."

// that's the ID you'll find in your Google+ profile URL
def myProfileId = "114130972232398734985"

// and this is the URL of my activities
def myActivities = "https://www.googleapis.com/plus/v1/people/${myProfileId}/activities/public?key=${myKey}".toURL().text

// I simply parse the JSON payload
def root = new JsonSlurper().parseText(myActivities)

// I iterate over all the items, and print the date, the URL of the post, and the title
println "|=Date|=Title"
root.items.each {
    println "|${sdf.parse(it.published)}|[[${it.title.replaceAll(/\s+/, ' ')}>>${it.url}]]"
}
{{/groovy}}

Result

googleplus.png

Tags: google google+
     

Get Connected