How do I list my app users in facebook - facebook-graph-api

I'm trying to get all the users of my application. So far I found this method:
SELECT uid FROM user WHERE is_app_user = 1 AND uid IN (SELECT uid2 FROM friend WHERE uid1 = $user)
However this return my friends who are using the app. I want all users, whether they are my friends or not. Is something like this possible?

It is not possible for security reasons. You have to log your app users but there are restrictions about this issue. You can check it out from: http://developers.facebook.com/policy/

Related

Sitecore ECM op-tin and opt-out roles dates

I want to know is there any way to get user subscrition / unsubscrition to email campaign ?
Is it saved in one of databases/tables in MSSQL ?
If you use the approach with opting in and out being determined on the fact if user is in role, then it is stored in the aspnet_UsersInRoles table in your core database. This table does not keep the information when role was assigned to the user. That's why you cannot get information when user subscribed or unsubscribed to email campaign.
The only thing you can check is if user is in the role:
user.IsInRole(roleName)
The user's subscription is driven by the users role, but It is possible to get the users subscriptions in ECM, You just have to use the api.
You can get the contact from the email address:
string fullName = commonDomain + "\\" + Util.AddressToUserName(username);
var contact = Contact.FromName(fullName);
var subscriptions = contact.GetSubscriptions();
Once you have a contact you can call the GetSubscriptions() method which will return the recipient lists the user is signed up to. There are a host of other methods you can call on a contact and if there is a a way to get the date unsubscribed/subscribed it will be here.
If not reflect Sitecore.EmailCampaign.dll and keep looking! There might be some extra information in the automation states table in the Analytics database. More info on automation state here:
https://www.sitecore.net/learn/blogs/technical-blogs/sitecore-magnified/posts/2013/09/ecm-automation-states-magic.aspx
Also noticed there is a method GetUnsubscribersStatistics on the Sitecore.Modules.EmailCampaign.Core.Analytics.AnalyticsHelper class. This will have the date of unsubscription.

Facebook Unity SDK - get list of friends which use the application

I'm using the Facebook Unity SDK 5.0.3 (building an Andorid player) and running into an issue trying to get a list of the friends which use the application. Have found various examples which use fql for that purpose, e.g "'/fql?q=SELECT uid, name, is_app_user, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1'", but using the last in FB.API ended up with "400 Bad Request" error.
Any ideas?
10x
Well, manage to find the solution. The problem was using FQL from JavaScript documentation example as is. The following code does the work:
var fqlQuery = "/fql?q=" + WWW.EscapeURL("SELECT uid, name, is_app_user, pic_square FROM user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me()) AND is_app_user = 1");
FB.API(fqlQuery, Facebook.HttpMethod.GET, GetFbFriendsCallback);
The GetFbFriendsCallback code can be found in Smash Friends sample application provided with SDK.

Batch retrieval of friend profile photos

I have successfully retrieved up to 50 user's profiles using the batching method. I attempted to use the same process to retrieve these user's profile photos, but get an error 302. I see that there is a URL pointing to the photo returned in the result, but using that to retrieve each photo would defeat the purpose of batching, which is to retrieve all at once and prevent repeated HTTP requests. Is it possible to retrieve these using the batching in the Facebook API?
Try FQL:
SELECT pic_square FROM user WHERE uid IN(SELECT uid2 FROM friend WHERE uid1 = me())
...where pic_square can be one of pic_small, pic_big, pic_square, pic
That'll give you URLs for the corresponding user's profile picture at the given size.
e.g.:
https://developers.facebook.com/tools/explorer/?method=GET&path=fql%3Fq%3DSELECT%20pic_square%20FROM%20user%20WHERE%20uid%20IN%28SELECT%20uid2%20FROM%20friend%20WHERE%20uid1%20%3D%20me%28%29%29

find which friends of user like facebook "PAGE"

I have a Facebook page and few apps built for it, and obviously have few fans of the page.
I'd like to know which friends of the currently logged in user (who is already my fan) are also my fan, i.e. find out how many users in current user's friend list are fans of my page.
I've tried to use friends.getappusers, but its deprecated.
FQL:
SELECT uid FROM user
WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = ?)
AND is_app_user = 1
--again an app usage.
OLD API: $facebook->api_client->friends_getAppUsers();
GRAPH API: $facebook->api(array('method' => 'friends.getAppUsers'));
I Know an app can do this.. but that wont help, I want the page to likes to be measured and not the app likes or usage..

Getting users friend data using FB Graph API

I am attempting to access a user's friends work and education history using the Graph API. I have included both permissions in the auth dialogue. I have tried accessing them using FQL but have had no luck.
try{
$fql = "select friends_education_history from permissions where uid=" . $user;
$param = array(
'method' => 'fql.query',
'query' => $fql,
'callback' => ''
);
$fqlResult = $facebook->api($param);
}
catch(Exception $o){
d($o);
}
}
I'd prefer to access the info without using FQL but at this point, I need to figure out ANY way. Is there a way to do something like this:
if($user_id) {
try {
$friends = $facebook->api("/me/friends");
}
catch(Exception $o){
d($o);
}
}
?>
And then call the respective variables?
Your FQL query would look something like this:
SELECT education,work from user WHERE uid IN (SELECT uid2 FROM friend WHERE uid1 = me())
Above query will fetch all education and work objects from friends of the logged in user.
SELECT education,work from user WHERE uid = <YOUR FRIENDS USER ID>
Above query will get education and work for just the one user id you provide
Hope this helps!
The User graph api object has fields education and work.
Permissions user_education_history & friends_education_history are required for the first, user_work_history & friends_work_history for the second.
These fields are optional & a user can restrict their visibility via her profile page, so even having granted the permissions the api may return nothing.
Use the Graph api explorer to have a play.