Checking online users with Facebook Javascript SDK - javascript

I'm trying to build some kind of a social game in facebook, where I need that every user that has approved my APP is able to receive notifications from me.
When the user approves my App, I save his UID in the DB for future reference.
At some later time, I want to make it possible for other users find partners for a game - so I need a way to pick randomly some user from my DB and check if he's online. Then, send him a message and propose to play with the current player.
So 2 questions:
How can I check if some user is online, using Javascript SDK? It seems that in the new Graph API I can't get the users' online status.
How can I then send him a message and propose to play the game? When he approves to play - he is being forwarded to the game page.
Many thanks in advance,
Roman

To get the user status you can try FQL, check this answer: How to get list of online friends using FQL with facebook API?
About your second question, check this: how send message facebook friend through graph api using Accessstoken

Related

We are using angular-agora-rtc web, how to check user is active in Agora server.?

We are using sample from https://github.com/AgoraIO-Community/Angular-Agora-RTC The channel name is hard coded in the sample. When 2 users need to connect for a call. Ideally both should be on same channel. Is there a way for user-1 to check whether user-2 is online using agora-web-sdk?. If the user is online, how can user-1 share a channel-id with user-2?
One-to-one video call implementation using agoara sdk. For 2 user to have a call, they should be in same channel. Link above has the sample I am trying. Not sure how two user share same channel name with each other being in 2 different mediums at real-time.
https://github.com/AgoraIO-Community/Angular-Agora-RTC
If agoara provides an API to check if user-2 or user-1 is online after these user's have created clients in web. Is there a way to exchange "channel id" between active users.
There is no such answer to this question anywhere on internet believe me i have searched for it, only thing that came to my mind is to use some type of User Base like Firebase, PHP MySQL etc to setup user and then login those users in your app.
After logging in, set various flags for user presence like is_online, last_active, is_broadcasting, is_audience etc to determine which user is online.
You can then put channel name along with other user details when the user login and starts the Broadcast.
After the user is broadcasting, use those flags you used before and query them to get the broadcasting users and show them where ever you want for other users to join their broadcast.
This as simple as it can be in terms of explaining a really frustrating problem but in the end its only you who would have to implement any type of logic you can come up with.

Play Games Services for Web - Turn based Game - Creating and Joining room in Javascript

I created a Simple Web Board game, where each user takes a turn and make their move.
I am now trying to integrate Google Game Play Services to connect 2 friends and let them compete.
With reference to https://developers.google.com/games/services/web/api/turnBasedMatches#methods
While creating a match, I am to pass invitedPlayerIds, which will be the player ID of my friend. But how will I get the ID of the friend, who is logged into his own device?
I was checking this Rooms API # https://developers.google.com/games/services/web/api/rooms
Seems most methods are only for Internal use. We can't create, list and join rooms.
Please advice me on how to proceed?
Edit 1: I can write a custom web service to exchange the Player IDs between the players. But I really dont want to do that and it adds more complexity. I believe, this could be done with the GPS itself somehow. But dont know how!
Edit 2:
I tried adding the mail ID of the player in invitedPlayerIds field of https://www.googleapis.com/games/v1/turnbasedmatches/create request body.
But it says Invalid playerId with value gethugames2020#gmail.com
Another way would be showing their own cryptic player IDs (like "g04345703229741133710") to the users, Let them communicate the ID via other means (SMS, WhatsApp) and ask them to manually type it into the game.
My Development work is # http://www.gethugames.in/tic-tac-toe-extended/
You can click the badge at the bottom to see the Achievements API (After logging in)
In order to use the Google Play games services, your game needs to implement user sign-in to authenticate your player's identity with the Google Play Games services. If the user is not authenticated, game will encounter errors when making calls to the Google Play games services APIs.
To get the current signed in player ID, if available. Use 'getCurrentPlayerID'
You may check the Quality Checklist for Google Play Games Services: https://developers.google.com/games/services/checklist#improving_the_sign_in_experience_for_games

PHP/Javascript Web application invite friends

Application Basics:
Not a game
Native / custom AnjuarlJS UI with PHP server-side code
I am loosing my mind here. I have looked around for over a month for a solution and I am finally posting a question for help.
I have a web application that I am building for a friend. This application is built with a JS(AngularJS) front end and a PHP backend. I have been able to get logic in place for facebook login and allowing users to link a facebook account to their local account in my app. The problem item here now is that we want to be able to allow users with facebook tied to their account to be able to invite their facebook friends to also us our website. With this I want to be able to know the app-scoped ID for the users the invite is sent to to be able to automatically associate the users once the invited friend creates and account via the link.
User A wants to invite User B to the application.
System stored ID of user B
User B clicks on the link and creates an account on the application.
System checks User B's facebook id against list of stored invited ID's
If the system finds the user id the application should be able to now associate them as friends in our native database
Sure I could created a url as such : www.app.com/facebookInvite.php?fromUser=123
but this does not allow the situation where User A AND User C invite User B to the application. Does ANYONE have a solution to this situation? I have yet to find an answer that involves not being a game.
(I hope my question doesn't confuse anyone)
Unfortunately, you cannot know and record B's facebook id without B installing your app. This is changed when they introduced app-scoped ids.
I think the only thing you can do is that store the request with id-name pairs and when B installs the app, check the requests table if B's friends has installed the app and they sent a request to B.
For instance,
Lets say Michael (A here) has id 12, and Dwight has id 11.
inviter_id inviter_name invited_token invited_name
12 Michael as1231e67dqd2e Dwight
When Dwight installed the app, he should have Michael as a friend with id 12. You can then check this table if Dwight is invited by his friends (Michael, Mose etc...) Since the names you stored in invited_name are not unique, this may give wrong results.
I hope I understood your question right :)

Grokking client-side Facebook connect?

I have client-side FB connect working. In my example you just click login with Facebook and then a popup appears, they login and then are returned to the app, where I display their name and pic.
My questions are around how to make use of this connection.
If they are using fb to log in would I create an account with this
information the first time? Then supplement this info with app specific stuff? Then grab that account every time they login? How should I reference the existing account?
Can I only query the API for data from the client, or can I store some info on
the server that lets me query their account from the server?
How would something like finding out if two people are friends work?
Would this be done on the server? What does the query look like?
How long do sessions last and how is it decided? Will the login persist across multiple visits?
Can I make use of the login when the user isn't currently active in the app? Query for a status or make a request on their account in between visits?
Any help figuring out how this works would be spectacular. Thanks very much for the help!
If they are using fb to log in would I create an account with this information the first time? Then supplement this info with app specific stuff? Then grab that account every time they login? How should I reference the existing account?
Yes, and you'd use their Facebook ID to find if they have an existing account.
Can I only query the API for data from the client, or can I store some info on
the server that lets me query their account from the server?
Store the access token. If you need long-lasting access (the default token expires after an hour or two) you need to request offline_access extended permissions.
How would something like finding out if two people are friends work? Would this be done on the server? What does the query look like?
Fetch a user's friends list from https://graph.facebook.com/me/friends and see if the friend's Facebook ID is in there.
How long do sessions last and how is it decided? Will the login persist across multiple visits?
When the user authorizes your app via OAuth, the expiration time in seconds is appended to the URL.
Can I make use of the login when the user isn't currently active in the app? Query for a status or make a request on their account in between visits?
Yes, until the token expires. See above regarding offline_access.

How can I hook up facebook connect with our site's login?

I want to implement something similar to what Digg has done.
When the user logs in for the first time, I want it to force them to create an account on my site.
More importantly I want to know how to log a user into my site when they login with facebook connect. If they login with facebook connect, they still haven't provided me the password to their account on my site, so I can't use username/password to log them into my site. How do they do this on Digg or sites similar to this?
Facebook's process flow can definitely be a bit confusing. Take a step back from the details and the API, and look at the overall flow here:
Facebook Connect will tell you that a user is logged into Facebook, and give you their Facebook ID. You can validate that ID against Facebook using Facebook Connect to make sure it is properly logged in. Once this is done, you don't need a user name and password. As long as you trust that Facebook has authenticated the person properly, they are the only ones that can come to your site using that Facebook ID. That is enough information to start an authenticated session based around a local account that is associated with that ID.
The process you should follow is like this:
User logs in to your site with
Facebook Connect for the first time
You notice that you don't have a local account associated with that
Facebook ID, and prompt them to
enter local account information
You save that information along with their Facebook ID
The next time you see that Facebook ID (and validate that it is
logged into Facebook using the
Facebook API), you can start up a
local session using the associated
account.
Basically you end up with two separate methods of authentication: a Facebook Connect ID check, or the regular username/password login on your site. Either one should have the end result of starting a local authenticated session.
Hope that helps.

Categories

Resources