I am trying to use the Google Health API with a REST API. I am aware there is an API available for Android but I am trying to port that behavior to a back end.
I am playing around in the Oauth playground; I am trying to get a aggregated query. I've tried many things but none of them return anything (only get errors) There is no example featured on the google website itself. Anyone has experience with this API?
I have found a few examples here on stackoverflow but none of them conclude with a solution or a full query that can fit as an example.
Here and Here
If I just could get a working aggregate example I would work from there.
Here is my request to https://www.googleapis.com/fitness/v1/users/me/dataset:aggregate:
{
"startTimeMillis": 1451647796000,
"endTimeMillis": 1458127796000,
"aggregateBy": [
{
"dataTypeName": "com.google.height"
}
],"bucketByTime": {
"period": {
"type": "day",
"value": 1,
"timeZoneId": "org.joda.timezone.DateTimeZone"
}
}
}
Response:
{
"error": {
"code": 400,
"message": "Bad Request",
"errors": [
{
"domain": "global",
"message": "Bad Request",
"reason": "invalidArgument"
}
]
}
}
You forgotten "durationMillis" field on "bucketByTime" and "dataSourceId" on "aggregateBy".
Timezone syntax is like "America/Los_Angeles" not "org.joda.timezone.DateTimeZone". You can see this strings on http://joda-time.sourceforge.net/timezones.html
Related
I am trying to get the birthday from the Google API, but the retrieved data in HWIOAuthBundle do not contain it.
I am wondering if the specified scope for google plus api in config.yml is correct or not!
If not, please give a link or the corrected scope.
google:
type: google
client_id: %client_id%
client_secret: %secret_id%
scope: "https://www.googleapis.com/auth/userinfo.email https://www.googleapis.com/auth/userinfo.profile"
paths:
email: email
profilepicture: picture
I just used and tested it using Try It. I tested it with all of the different scopes.
https://www.googleapis.com/auth/plus.login Know your basic profile
info and list of people in your circles.
https://www.googleapis.com/auth/plus.me Know who you are on Google
https://www.googleapis.com/auth/userinfo.email View your email address
https://www.googleapis.com/auth/userinfo.profile View basic
information about your account
It doesn't appear to matter you get back the birthday in all of the scopes. But what does matter is that the Users Birthday must be set to public in the Account. If it's set to anything else, your circles, only you, it's not listed. This appears to be true even when you are trying to see your own information. (Sending Me.)
Update and the year is 2018
The People api now returns the birthday of the current user
People.get However i suspect its linked to google+ so if the user hasn't filled it out you probably wont get info.
GET https://people.googleapis.com/v1/{resourceName=people/*}
Send Resournce name of people/me and birthdays personFields
{
"resourceName": "people/117200475532672775346",
"etag": "%EgQBBzcuGgwBAgMEBQYHCAkKCwwiDDQwaGhWYzc3cXJBPQ==",
"birthdays": [
{
"metadata": {
"primary": true,
"source": {
"type": "PROFILE",
"id": "117200475532672775346"
}
},
"date": {
"month": 1,
"day": 6
}
},
{
"metadata": {
"source": {
"type": "ACCOUNT",
"id": "117200475532672775346"
}
},
"date": {
"year": 1971,
"month": 1,
"day": 6
}
}
]
Normally you will only get birthdays that have public visibility. To get private birthdays you need to use the https://www.googleapis.com/auth/user.birthday.read scope. See documentation for which scopes give you which data https://developers.google.com/people/v1/how-tos/authorizing#profile-scopes.
I want to access the Person's gender and age group via Google People API. Can we fetch the information without getting the user signed in from our app?
That depends interlay upon what they have set to public. You can use people.get with a public api key. All you need is the API key from the Google Developer console and the Id of the person in question.
110241806600768156114
The Request
GET https://www.googleapis.com/plus/v1/people/110241806600768156114?key={YOUR_API_KEY}
Response
{
"kind": "plus#person",
"etag": "\"RqKWnRU4WW46-6W3rWhLR9iFZQM/uQPoHyS74SJW3R-WzeaqLgt_EL8\"",
"gender": "male",
"objectType": "person",
"id": "110241806600768156114",
"displayName": "djordje tankosic",
"name": {
"familyName": "tankosic",
"givenName": "djordje"
},
"url": "https://plus.google.com/110241806600768156114",
"image": {
"url": "https://lh6.googleusercontent.com/-XtK8-6zkQHY/AAAAAAAAAAI/AAAAAAAAAJk/hI2NqHzmNrA/photo.jpg?sz=50",
"isDefault": false
},
"isPlusUser": true,
"circledByCount": 18,
"verified": false
}
This person who I just randomly grabbed there Id off Google+ has gender set to public. As you can see there is not much other information available to you.
I suggest you go to the bottom of the people.get page and do some testing with the try me don't authenticate it. This will ensure that you are only checking public access. If you want to see the different authenticate it then use 'me' in the id field. This will show you the response for an authenticated user.
Trying to use IO Keen for Android, i'm using Android Sample available here (https://github.com/keenlabs/KeenClient-Android-Sample) the data is being sent, but they are always duplicate and the second always contains junk.
The HashMap event is clean before adding in the queue.
Am I the only one?
Watch these :
{
"keen": {
"timestamp": "2015-01-22T18:08:49.863Z",
"created_at": "2015-01-22T18:09:07.589Z",
"id": "54c13cc3672e6c486c7a28bb"
},
"click-number": 0
}
{
"keen": {
"timestamp": "2015-01-22T18:09:07.590Z",
"created_at": "2015-01-22T18:09:07.590Z",
"id": "54c13cc3672e6c486c7a28bc"
},
"-537732783": 3
}
"-537732783": 3 What is that?
Logcat :
FINER: Sent request '{"android-sample-button-clicks":[{"click-number":0,"keen":{"timestamp":"2015-01-22T13:14:19.075-0500"}}]}' to URL 'https://api.keen.io [...]
FINER: Received response: '{"android-sample-button-clicks": [{"success": true}]}' (200)
FINER: Sent request '{"android-sample-button-clicks":[{"-1236199318":1}]}' to URL 'https://api.keen.io [...]
FINER: Received response: '{"android-sample-button-clicks": [{"success": true}]}' (200)
This was caused by a bug in the 2.1.0 release of the SDK. It has been fixed in the 2.1.1 release.
(In more detail: the bug was in the retry limiting logic that was added as part of 2.1. See this PR for the fix: https://github.com/keenlabs/KeenClient-Java/pull/37)
Sorry for the mistake!
I am developing an android game and i am trying to use Facebook's graph Api to create a leaderboard for my android game integrated. how can is post my score in game to facebook ?
here, i'm trying to call following facebook graph url.
https://graph.facebook.com/10000557xxxxxxx/scores?score=2200&access_token=CAAGmYpJsHQYBACuYb5zEgF1kyKU9nwHFJNkn7ZBZCbZCmGogNR3Ls5SuQ0xECYDUZAcFVZAL5awcCruvpx1NhgYPeqmP84e4ribBFmmthDYwl6jbCbwX51dpg5eZAEurIBxxxxTAmMmC6q2kKhx7A9p8EZBHJS407IQ6BKT3tGnNZBoHByr2uJoH78ZBWbZAYmLMh8RMUmzEdl9UDfxxxxxxxx
but i have getting following response, but it contains my old score every time.
{
"data": [
{
"user": {
"id": "1000055754xxxxxxx",
"name": "Sumit Paxxxxxxxxx"
},
"score": 2029,
"application": {
"name": "Cute",
"namespace": "cute",
"id": "4644172702xxxxxx"
}
}
]
}
You need to do a POST request instead of a GET one. See:
https://developers.facebook.com/docs/graph-api/reference/v2.2/user/scores/#publish
Sample:
POST /me/scores
with the following body:
score=2200
I want to show the profile picture using the graph api using the following link fpor example :
https://graph.facebook.com/me/picture?redirect=0&height=200&type=normal&width=200
I get the response :
{
"error": {
"message": "An active access token must be used to query information about the current user.",
"type": "OAuthException",
"code": 2500
}
}
Where in the link they say
Because profile pictures are always public on Facebook, this call does
not require any access token.
The me in the URI is just a placeholder, you need to put an actual Facebook user-id in, like the title (/{user-id}/picture) of your linked page suggests.
For example:
https://graph.facebook.com/snoopdogg/picture?redirect=0&height=200&type=normal&width=200
...returns the following:
{
"data": {
"url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-ash3/c11.0.433.433/s200x200/598452_10151897536239807_882122819_n.jpg",
"width": 200,
"height": 200,
"is_silhouette": false
}
}