Facebook Graph API 2.2 mutual friends - javascript

So I've been trying for this for a couple of days, trying to figure out how to use Facebook's Graph API v2.2 to get mutual friends between two users. I understand that I can only get the mutual friends between two users that are using the FB App and that's cool.
The app has the following approved items:
email
public_profile
user_birthday
user_friends
user_hometown
user_location
user_relationships
user_website
My scenario is this:
A user (user A) register to the FB App
Another user (user B) registers
User A looks at the user B's profile
The profile should display the mutual friends between the two users
I've tried to play around in the Graph API Explorer
/v2.2/app_scoped_user_id?fields=context.fields%28mutual_friends%29
and
/v2.2/user_id?fields=context.fields%28mutual_friends%29. These just returns an ID field with the ID I provided and nothing else.
I'm all out ideas, and the docs isn't helping much either. Can someone explain how to do it?
I will be using it in an Angular app but as long as I can get the URL to fetch the correct thing I can translate it into Javascript.

For v2.3 - https://developers.facebook.com/docs/graph-api/reference/v2.3/user.context/mutual_friends
Between friends make sure the user_id in the query is the Facebook id of the other friend not the current user whose access token you are using.
GET /v2.3/{other_user.user-id}?fields=context.fields%28mutual_friends%29
For querying mutual friends between two non-friends you need to add a server appsecret_proof parameter plus the user access token.

Related

Discord JS - How to get links to connected accounts of a user

Is there a way in which I can retrieve the links to all the social medias and other accounts a person has connected to their discord account?
I searched the docs to no avail and tried looking in the user object but I found nothing. I assume there must be some way in which I can retrieve this information?
As far as I know it's not possible with just the code of the bot. To get the connections, you must bring the user to authorize your application Oauth. Its like adding a bot to a server, but instead of doing this the user authenticates the bot to get some information about the user.

Google oauth2.0 with a web app for an organization?

I'm attempting to pull calendar data (FreeBusy query) for employees in our orgs for a web app so that users can know whether or not they should contact that user right now. When trying to hit the FreeBusy api endpoint I get a 403 as expected, how can I authenticate with Google to allow this user (or app) to pull the information from the API?
Is it possible to create an "app authorization" token with a client username/password to pull this data from the google dev console? Or do I have to use some sort of redirect to google auth url and let the user authenticate there and provide a callback url?
Alternatively, is there any way to include google auth when the page loads? Is there a way to sort of "pop up" the google account you want to use and let google then generate an access token based on that?
The simple flow looks like this:
User enters some data about what they need into a frontend form (javascript app)
Call my own API and determine which employees match X criteria.
Take this result set and check the calendars of these matches. If they're available then allow user to contact them.
In order to access data of other employees, not one that initiated the request, you will either need those employees to each consent to your use of their data or (this is what would generally be done) get the admin of your organization to approve your app on behalf of all users in the domain.
If you do the latter, you can use domain-wide delegation [1] using a service account to pull the information you need.
[1] https://developers.google.com/identity/protocols/oauth2/service-account#delegatingauthority

Generate Tokens using twitter login

What i want :
I need to create a twitter application in which i will be providing user login, once user gets logged in, it should ask user to give permissions for Direct message and tweets, once user allows for it, i need that user's Consumer API keys Access-token and access token secret keys
What i did :
I have created an application for my Twitter account, I have generated
Consumer API keys Access-token and access token secret keys for
my application, now which way i should go?
I have seen couple of application which asks users to get logged in and their application generates access token n etc for logged in user, and stores to their DB, which can be used later on for sending and receiving DMs and tweets in customer support like applications.
I am looking to do it using java-script.
Your help would be appreciated.
Please let me know if you required further details.
I wrote a Javascript application that allows users to schedule tweets, retweets, and like tweets, and it uses technology you are asking about.
It does not generate Access Tokens & etc. for the user, because that's Twitter's job... But once the user collects those from Twitter and saves them in my application, you can set up tweets, and schedule when they should go out, and it will Tweet to your account for you using the Twitter API.
Here is my app, you can look through as an example, or even download yourself and run locally on your computer.
Here are the code files on GitHub
This is the live app! Try It!
Your apps needs a server, and if you run a Nodejs server, you can use this NPM package to make interacting with the Twitter API very very easily. IT supports, Tweets, Media Uploads, DMs, Streams, almost everything!
NPM Twit
If you want users to be able to login into your website/app using their Twitter account, you can use Passport.js to easily accomplish this. Search on YouTube, there are many many tutorials.
Passport + Twitter Auth Strategy
Good luck!
EDIT: To answers you're comments: Yes - you can get/send Tweets and DMs on behalf of another account. You MUST acquire the API KEY & SECRET and the ACCESS TOKEN & SECRET. The client MUST provide these to you. There is no other way to Tweet and DM for other accounts, aside from getting their password and logging directly into Twitter. Read Twitter Developer Docs.

How can we extract the complete Facebook friend list using Graph API in java script?

I am trying to extract friends list of a profile. I tried looking for the help and only thing I got is, "/me/friends"
but this call has a limitation. This will only return any friends who have used (via Facebook Login) the app making the request.
I wanted to have the list of all the friends in my profile.
That´s how it works, you can´t get the full friendlist anymore. See the changelog for more information: https://developers.facebook.com/docs/apps/changelog
You can only get the friends who authorized your App too, for privacy reasons.
There are also plenty of other threads about that question already, for example:
Facebook Graph Api v2.0+ - /me/friends returns empty, or only friends who also use my app
Get ALL User Friends Using Facebook Graph API - Android

Displaying friends' user who authenticated the app

I'm going more in depth in the Facebook javascript sdk but I am still new to it. I would like to display for every user on my website who logged with Facebook, their friends' pictures who also authorized the app. It is clearly and simply possible by using PHP SDK, but I only want to make use of javascript SDK to improve the speed of my site. Does anyone have an idea ?
Best,
Newben
You can use FQL to query the current user's friends SELECT id, name FROM user where uid IN (SELECT uid1 FROM friends WHERE uid2=me()) AND is_app_user=1. This query does two things. Finds all the friends and find only the friends who have your app installed.
For additional information see:
http://developers.facebook.com/docs/reference/fql/user/
and
http://developers.facebook.com/docs/reference/fql/friend/

Categories