Filter Friends that are Online FBML - facebook

Ok, I have this array of a users friends, and I'm just wondering how I can filter out the ones that are offline so that I only have the online ones in the array :D
Thanks

You don't need to do that, you just have to account for current logged in user whether it is you or anyone else and behind the scenes it will be however is logged in. You should simply make a check if a user is logged in (any user including friend):
if ($facebook->user > 0 && isset($facebook->user))
{
// your code here....
}
The code in the condition will run only if a user is logged in.

Related

Unity Facebook SDK: FB.IsLoggedIn / FB.ShareLink issue

I'm trying to create my mobile app user to share my Facebook page and if they do, I give them an in-game item. I'm using the example code provided by Facebook here: https://developers.facebook.com/docs/unity/examples
The first issue is that FB.ShareLink doesn't comeback negative if the user cancels the sharing action. From what I've read, that's on purpose and it only works correctly if the user is logged in and my app is authorized. I tested it and that's true, if I use the login code to first login, it comes back as positive or negative correctly.
The second issue that I'm having though is that FB.IsLoggedIn never comes back negative and I'm not sure how to properly check this because even though it comes back as true, my app is note authorized and FB.ShareLink doesn't return negative when canceled. I start the Login issue and then I press the back arrow to cancel it but FB.IsLoggedIn still comes back as true.
How can I just check if the app is authorized? I'm guessing that's all I need to check before running the FB.ShareLink code.
Any ideas?
Thanks!
First, we try to login asking for the user's e-mail address.
public void LogIntoFacebook() {
List<string> perms = new List<string>() { "email" };
FB.LogInWithReadPermissions(perms, OnLogin);
}
Then you can check to see if you got the e-mail address permission using
AccessToken token = AccessToken.CurrentAccessToken;
if (token.Permissions.Contains("email")) { // do something }
If you do, then you move forward with the Facebook share.

Is there anyway to know when user is logged in to tumblr via javascript?

I am looking for ways to do this. API doesn't seem to be helping. I tried many ways without api too. I need to achieve this with javascript.
Does anyone know any kind of way to do this?
I have tried something like this:
How to detect if a tumblr user is logged in?
https://github.com/apandhi/Tumblr-Logged-In-Checker
which is without api. I can't find how to do this with api and I am not sure if it's even possible.
To update my comment.
If you run this code on your blog (or in the console)
document.cookie.indexOf('logged_in=1') != -1;
It returns true if user is logged in, or false if user is not logged in.
By this logic you can set this equal to a variable and run different functions depending on the value of the variable.
var user_logged_in = document.cookie.indexOf('logged_in=1') != -1;
if(user_logged_in) {
// insert code here for logged in users
}else{
// insert code here for non logged in users
}

How to check if other users are logged in on Parse via Facebook or some other way?

I know that if I want to check if PFUser.currentUser is logged with Facebook, I can use:
if FBSDKAccessToken.currentAccessToken() != nil {
print("you logged with FB!!")
//do your stuff.
}
How can I know if in a blogging app, another user is logged on parse via Facebook? (or twitter? or other ways?).
So just to be clear, I don't want to know if CURRENT USER is logged in via FB!, but if ANOTHER user is, still better HOW this user logged in.
For example, in a class named "posts" under the column "author" I have pointer to that user in default "users" class. Is there a way, planned by Parse, in wich I can perform that check? In their docs this case seems to be missing, they only talk about login, linking, referring, but not checking (if not for current user).
should I insert a new column in class User as for example "userLoggedInBy" ??

Meteor keep track of user sign ins

I would like to keep track of the amount of times that a user has logged into the application to either:
Remind them on their first visit to complete their profile
If profile is not complete, every X amount of visits remind user to complete
I'm not sure if the proper way to do this would be adding a key value to the users collection, or tie login to a new collection which counts up one each time a login occurs.
Is there a built in method to keep track of login successes?
Yup. You can even keep track of login failures.
From http://docs.meteor.com/#/full/accounts_onlogin:
Accounts.onLogin(function() {
// track successful login here. You can just use Meteor.user() to find out which user.
});
Accounts.onLoginFailure(function() {
// track failed login here.
});
There is even a "validate login attempt" method where you could potentially screen your users:
Accounts.validateLoginAttempt(func):
Accounts.validateLoginAttempt(function(loginInfo) {
// loginInfo.user returns a valid user object, if logged in successfully. Maybe tie this one to a collection, and do some checks etc.
// you can even use loginInfo.connection to see where the user has connected from (e.g. IP address.. perhaps)
return true; // return false if you want to 'bounce' this user.
});
Note: These can be done server-side only.

is admin on facebook pages

I looked around and could not find anything to do this (well it was not obvious or semi-obvious)
So say i have a facebook application that offers a service that people will pay for during use. The average user can come on and "Subscribe" to it, while the admin of those pages can perform an activity that will cost them money (make me money).
I do not want hacking attempts or anything to hurt our product. So, how can i verify that someone is an admin using the PHP SDK.
What we are currently doing is storing the $_POST["signed_request"] in $_SESSION's data and working with that. Either the $_POST or $_SESSION is not safe 100% (firesheep).
Is there any way to verify this? graph api?
Okay, first things first. To retrieve the signed_request and check if the user is an admin you would use something like:
$signed_request = $facebook->getSignedRequest();
if ($signed_request['page']) { // Loaded in a page tab
if ($signed_request['page']['admin']) {
// Current user is admin
} else {
// Normal user
}
} else { // Canvas view
}
Now I'm not sure what do you mean by:
What we are currently doing is storing the $_POST["signed_request"] in
$_SESSION's data and working with that.
Because if you are using the PHP-SDK then you don't need to worry about storing the signed_request in the session since the SDK will handle it for you.
Now for the last part:
Either the $_POST or $_SESSION is not safe 100% (firesheep).
That's not true, the signed_request is useless without your app secret key to decode it. So even if someone was able to obtain it, it won't compromise your application. Read more about signed_requests here.