Publishing Open Graph Action to Groups - javascript

I would like to be able to publish OG Actions to Facebook groups. I am able to publish the action as follows:
POST https://graph.facebook.com/me/appfoundry:annotate
{article: http://synchro.herokuapp.com/articles/10}
This works great, and the annotation shows up in my news feed. But when I try to publish to one of my groups,
https://graph.facebook.com/305900672779368/appfoundry:annotate
{article: http://synchro.herokuapp.com/articles/10}
I get the following error:
{
"error": {
"message": "(#240) Requires a valid user is specified (either via the session or via the API parameter for specifying the user.",
"type": "OAuthException",
"code": 240
}
}
I would like these actions to be visible only in the groups, which might be private or secret, and I do NOT want them to show up in a user's news feed or ticker.
I am using the Graph API Explorer with my app selected, which has user_groups, publish_stream, publish_actions, share_item and status_update permissions.
What am I missing?
Thanks,
Marty

This is not possible, only Users can publish Open Graph actions.
A user can choose who can see their actions, but can't currently only allow just members of a group to see those actions.

Related

How to get avatar for gmail user?

I'm creating an email-based application in React with the Gmail API. I'm loading in a bunch of messages, and I want to display avatars of the senders.
I'm using this package to display avatars. I'd like to either have a Google Id or an image url. It would also be nice to be able to get images for other popular services, such as Outlook and Yahoo mail.
Other people have asked this same question, but all the answers either seem to use the Picasa API (which is deprecated) or the Google+ API (which will be deprecated).
EDIT: Yes, the react-avatar package claims it can find an avatar based on supplied user data, but all it does with the email is find a Gravatar, which many people don't have.
What you want to do is not possible via the GMAIL API or any other Google API
You can not take a Google email address and search for the image or any other personal profile information associated with that email address via any Google API endpoint. Explanation below.
Get image of the sender of an email
Gmail API lists the email messages that have been sent to and by a user. The gmail API is basically returning the mail server email message response in MIME format which if you check does not contain a profile image. It does not return to you the image of a the sender or the reciever.
Google does not have endpoint for developers to use to searching on a gmail.com email address and returning any user profile information (including image) this would be against the users privacy. A user would have to grant you permission to see their image and you dont have that permission for every gmail user who may be sending emails to your authenticated user.
The gmail website probably does some kind of check on gmail email addresses and puts the picture on attached with the account. Google has access to the profile data of all GMAIL users, google cant give you this same access as it would be against the users privacy. If its not a gmail account they may check Gravatar to see if an image has been set up for this email address. Again there is no way for you to request the image of a google user using their email address.
You could check Gravatar to see if one had been set up for that email
If the authenticated user has added this user as a contact and has added a picture for this user you may be able to use the People api.
In the past i have recommend to users that as an image they take the first letter of the users email address and create an image using that letter. You may also want to use a question mark which is actually what gmail does when its website cant find an email from the user probably by checking Gravatar.
Get image of current authenticated user
You can get this information from the people.get endpoint just make sure that you have requested the profile scope from the user when you authenticate them
GET https://people.googleapis.com/v1/people/me
It returns a large response containing the users profile information part of it contains the users picture
"photos": [
{
"url": "https://lh3.googleusercontent.com/a-/AAuE7mDuIWqXzrrp-65cIhXSD2HjCI8WYsWHR0fDx5_wQPY=s100",
"metadata": {
"source": {
"type": "PROFILE",
"id": "117200475532672775346"
},
"primary": true
}
}
],
The offical sample project for people api contains information on how to connect to the api. Just make sure to add the 'profile' scope
The code to get the picture should be something like this.
function getPicture() {
gapi.client.people.people.get({
'resourceName': 'people/me',
'pageSize': 10,
'personFields': 'photos',
}).then(function(response) {
var connections = response.result.connections;
appendPre('Connections:');
if (connections.length > 0) {
for (i = 0; i < connections.length; i++) {
var person = connections[i];
if (person.url && person.url.length > 0) {
appendPre(person.names[0].url)
} else {
appendPre("No display name found for connection.");
}
}
} else {
appendPre('No connections found.');
}
});
}
I don't think that google shares that info with anyone without permission .
You have to create a profile for every user and take the profile image only once when the user registers in your platform by the Google oauth
Check this info
https://developers.google.com/actions/identity/google-sign-in-oauth
The currently accepted answer isn't entirely correct, as there absolutely is a Google API which exposes Gmail Avatars - as well as the user's first- and/or Lastname, as long as the user has configured any publically.
Although I have so far been unable to find the actual API endpoint you can use to achieve this, I did come across avatarapi.com.
As stated on their website:
This API uses public profile information provided by Google, via a publicly exposed Google data source to determine the name and profile image of the user.
They have a fallback to Gravatar. I'd also love to find out where this 'Google Data source' they use is located.
Gravatar
It is possible that the user associated with that email address has signed up for Gravatar. In that case, you can easily obtain the Gravatar avatar.
You need to get the md5 of the email first, then
var email = "youremail#gmail.com",
size = 80;
yourImg.src = 'http://www.gravatar.com/avatar/' + MD5(email) + '.jpg?s=' + size;
https://jsfiddle.net/a4g8s5y2/1/

Getting empty list on post reactions. What could be the reason?

I am trying to read reactions on a post using the following graph-api call:
FB.options({version: 'v2.12'});
FB.setAccessToken('EAACEdE7w4Fp85PlhH0NYpZBddHyqkx6XXXX')
FB.api('/765898450131958_1518951084826687/insights?metric=page_actions_post_reactions_wow_total', (res) => {
console.log(res)
});
But I always receive an empty data list. What could be the reason for this? For reference I am using FB module to connect to graph-api.
The acces token I am using is my page-access token
In my case, the facebook app instance wasn't set to live. Once the facebook app instance is live, data array returns user info list with id and name . You can check that out in App Review Settings
Click your app instance -> Go To "App Review" -> Click "My Permissions & Requests".
You will see that there are two approved items. I think these are added or granted by default. But if your app is not live, the two permissions will not be active. That includes basic user information like name and profile picture.
TL;DR - Check if your app is live and also make sure that you are using Page Access Token rather than User Access Token.
From official Facebook API documentation:
On February 5th, 2018, User information will not be included in responses unless you make the request with a Page access token. This only applies to Comments on Pages and Posts on Pages.
https://developers.facebook.com/docs/graph-api/reference/v2.12/object/reactions

How to comment in a closed group facebook api graph

I am developing on API Graph Facebook. I'm using JavaScript SDK. I want to comment in a group where I have published.
The problem is some groups are closed, although I am in these groups.
How can I comment in this groups?
For example, if I am in the explorer of Facebook developers I try to get a post mine, but when I execute the GET I obtain this error.
{
"error": {
"message": "Unsupported get request. Object with ID '114576608727103_527470874104339' does not exist, cannot be loaded due to missing permissions, or does not support this operation. Please read the Graph API documentation at https://developers.facebook.com/docs/graph-api",
"type": "GraphMethodException",
"code": 100,
"fbtrace_id": "DVXM6hFnfeF"
}
}
I have same problem when I try to use POST method. I can comment in a groups open normal.
Note: I am in all groups that I want to comment.
Thank you.

How to get list of all email address who opened my mails sent through mandrill api

Hi am sending emails to multiple email id's using mandrill API. Am getting the count for opens,unique_opens,clicks,unique_clicks,bounces and so on. what i want to capture is the email id's of the persons who opened and clicked my mails sent through mandrill API. and here is the link do get the count of the mails sent, opens and clicked.
The users/info API you found provides account-level summary info, like you'd see on Mandrill's dashboard. I think there are two possible approaches to getting Mandrill click/open data for individual recipient addresses:
The first would be to use Mandrill's exports/activity API to generate a summary CSV, of essentially the same info you can see on the Mandrill outbound activity dashboard: for each sent message, the recipient address, status, open count, click count, etc. -- exactly the info you're looking for, in one big file.
One downside is, exports/activity isn't synchronous. You call it, it initiates a request to generate the export, and then you have to keep polling to see if it's done. And then download the zipped CSV it's generated, unzip it, and parse the CSV. (So, you'll have to write a little code.)
The second approach is to use Mandrill's messages/info API to get the latest info for a specific message. The results include not only the open and click counts for that message, but incredibly rich detail about the opens and clicks: the user's IP, location and user agent, which URL they clicked, etc.:
{
"_id": "abc123abc123abc123abc123",
"email": "recipient.email#example.com",
"clicks": 42,
"clicks_detail": [
{
"ts": 1365190001,
"url": "http://www.example.com",
"ip": "55.55.55.55",
"location": "Georgia, US",
"ua": "Linux/Ubuntu/Chrome/Chrome 28.0.1500.53"
},
... for each click
],
"opens": 42,
"opens_detail": [ ... similar to clicks_detail ... ],
...
}
The downside to messages/info is, you have to call it once for each sent message -- which means you also need to be keeping track of the _id Mandrill assigns the message when you send it (in the messages/send response). (So again, you'll have to write a little code.)
With either approach, you'll need to experiment with when you run the queries. You'll want to wait long enough after a message is sent for most of the opens and clicks to have occurred. But, Mandrill stores the detailed data for only 30 days (I think) -- so, you won't want to wait too long.
If you are looking for more information like which URLs in the email were clicked, which browser etc. I would suggest using /messages/search.json which would return a maximum 3 months old data. search API returns the same info as info api, but it spans multiple messages as specified by the query. It is more efficient that sending a info message for each email that you sent.
Also there is a limit of 1000 messages per search query. So you have to size your time window accordingly, in your search query ts:[START_TIME TO STOP_TIME]
Hope this helps,

Facebook Graph not returning email

UPDATE It seems that my personnal email address had not been used for years. Facebook marked it as inactive and did not return it as part of the JSON.
I am authenticating a user with Facebook on the client side using this url :
https://www.facebook.com/dialog/oauth?
client_id=xxx&
redirect_uri=https://www.facebook.com/connect/login_success.html&
scope=email
I receive a code I then exchange for a token :
https://graph.facebook.com/oauth/access_token?
code=xxx&
client_id=xxx&
client_secret=xxx&
redirect_uri=xxx
I then send the token to my server and I fetch the Fb Graph in order to get some user info, including the email.
https://graph.facebook.com/me?access_token=xxx
For some reason, I get all the user 'about' info, but not his/her email!
What did I do wrong?
According to the Facebook Documentation:
By default, not all the fields in a node or edge are returned when you
make a query. You can choose the fields (or edges) you want returned
with the "fields" query parameter. This is really useful for making
your API calls more efficient and fast.
This is valid from v2.4, (previous versions retrieved some default fields).
When you register a new app you are entitled automatically (without manual review) to three permissions: email, public_profile and user_friends. In your code "email" is in scope (which is good) so just change your query to:
https://graph.facebook.com/me?access_token=xxx&fields=email
You probably wanted the public_profile fields that you automatically got in previous versions of the API. Do so so, add "public_profile" to your scope:
https://www.facebook.com/dialog/oauth?
client_id=xxx&
redirect_uri=https://www.facebook.com/connect/login_success.html&
scope=email,public_profile
And now add the user name fields to your query:
https://graph.facebook.com/me?access_token=xxx&fields=first_name,last_name,gender,email,timezone,age_range,verified
Good luck

Categories

Resources