Reputation: 5432
I am trying to request the posts from my google+ profile. I can get the data using the simple API and the default url. The API docs show what the options are, but don't explain how to use them. The goal is to set the maxResults option. Here is what I got:
$.ajax({
url: "https://www.googleapis.com/plus/v1/people/{my user id}/activities/public?key=dfaskjfklsjfldfsjsadlkjflsd",
type: "get",
success: function(data){
}
});
Upvotes: 0
Views: 280
Reputation: 50701
There are several ways to do what you're trying.
1) Request parameters for a GET are appended to the base URL after a question mark, and are separated by &. So your url might look something like
https://www.googleapis.com/plus/v1/people/{my user id}/activities/public?key=fldskjflkdsjaflsajflsjfasl&maxResults=10
one tool to help you with this is to use the "Try It!" section at the bottom of https://developers.google.com/+/api/latest/activities/list which will let you fill in fields and show you the HTTP request it makes.
2) In jQuery, you can also specify parameters for a GET URL using the data
field in the call to $.ajax. So this same example might look something like:
$.ajax({
url: "https://www.googleapis.com/plus/v1/people/{my user id}/activities/public"
data: {
key: "fldskjflkdsjaflsajflsjfasl",
maxResults: 10
},
type: "get",
success: function(data){
}
});
3) You can use the JavaScript client libraries available for download from https://developers.google.com/+/downloads/ (which also has sample code for how to use it).
Upvotes: 2