I really have spend hours to try to solve this question unsuccesfuly! I just want to be able to read any user's timeline (public messages) from facebook... Technically (for simplicity) I would prefer to only use frameworks from the iOS sdk (ie. not having to use the facebook one). Therefore I currently only use Social.framework and Accounts.framework
What I've succeed to do so far is to read the facebook timeline of the currently logged user (the one identified on the device) BUT when I try to sustitute the "me" by "ANOTHER_USER_ID" in the following url @"https://graph.facebook.com/me/feed" it only returns an empty data field (no "message" node).
The "strange" fact is that I can successfully reach any feed of corporate type (like "cocacola" for exemple) using @"https://graph.facebook.com/cocacola/feed".
So my question is how to reach the feed of a "simple" user (for exemple "shireesh.asthana"), so that I can read it's "message"?
My process so far :
Below is the code I'm currently using :
ACAccountStore *account = [[ACAccountStore alloc] init];
ACAccountType *accountType = [account
accountTypeWithAccountTypeIdentifier:ACAccountTypeIdentifierFacebook];
// Specify App ID and permissions
NSDictionary *options = @{
ACFacebookAppIdKey: @"1111111111111", // My AppID here
//ACFacebookPermissionsKey: @[@"read_stream"],
ACFacebookPermissionsKey: @[@"email", @"read_stream"],
ACFacebookAudienceKey:ACFacebookAudienceFriends
};
[account requestAccessToAccountsWithType:accountType
options:options completion:^(BOOL granted, NSError *error)
{
if (granted == YES)
{
NSArray *arrayOfAccounts = [account
accountsWithAccountType:accountType];
if ([arrayOfAccounts count] > 0)
{
ACAccount *facebookAccount = [arrayOfAccounts lastObject];
// I want the messages and the author
NSDictionary *parameters = @{@"fields": @"message,from"};
NSURL *feedURL = [NSURL URLWithString:@"https://graph.facebook.com/HERE_THE_USER_ID/feed"]; // Work with "cocacola" but not with "shireesh.asthana"
SLRequest *getRequest = [SLRequest
requestForServiceType:SLServiceTypeFacebook
requestMethod:SLRequestMethodGET
URL:feedURL
parameters:parameters];
getRequest.account = facebookAccount;
[getRequest performRequestWithHandler:
^(NSData *responseData, NSHTTPURLResponse
*urlResponse, NSError *error)
{
dataSource = [NSJSONSerialization
JSONObjectWithData:responseData
options:NSJSONReadingMutableLeaves
error:&error];
// Reach the main queue to process result
dispatch_async(dispatch_get_main_queue(), ^{
NSLog(@"Read %d messages", [dataSource[@"data"] count]);
if ([dataSource[@"data"] count] != 0) {
// Do stuff in case of success...
} else {
// Do stuff in case of ERROR...
}
});
}];
} else {
// Case of no facebook account on the device...
}
} else {
// User don't grant the app to access its facebook info...
}
}];
So my question is how to reach the feed of a "simple" user (for exemple "shireesh.asthana"), so that I can read it's "message"?
The reason could be -
The <user>
has no public posts,
The <user>
has Turn off Platform in the App Settings
(of-course, the <user>
here is not the user in session)
P.S. Shireesh Asthana (who works at Facebook), don't have any public posts