我真的花了几个小时试图解决这个问题,但没有成功! 我只想能够从 facebook 读取任何用户的时间线(公共(public)消息)... 从技术上讲(为简单起见)我宁愿只使用 iOS sdk 中的框架(即不必使用 facebook 框架)。因此我目前只使用 Social.framework 和 Accounts.framework
到目前为止,我所做的是读取当前登录用户(设备上标识的用户)的 Facebook 时间线,但是当我尝试用以下网址中的“ANOTHER_USER_ID”替换“我”时@ “https://graph.facebook.com/me/feed” 它只返回一个空数据字段(没有“消息”节点)。
“奇怪”的事实是,我可以使用@"https://graph.facebook.com/cocacola/feed "成功地访问任何公司类型的提要(例如“可口可乐”)。
所以我的问题是如何到达“简单”用户(例如“shireesh.asthana”)的提要,以便我可以阅读它的“消息”?
到目前为止我的过程:
- 在 https://developers.facebook.com/ 上创建一个应用程序获取 AppID
- 在我的代码中使用此 AppID 以便能够使用 SLRequest 发送请求
下面是我目前使用的代码:
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"?
原因可能是——
<user>
没有公开的帖子,<user>
在 App Settings 中有关闭平台
(当然,这里的<user>
不是 session 中的用户)
附言Shireesh Asthana(在 Facebook 工作),没有任何公开帖子
关于ios - 如何使用 iOS 社交框架阅读任何 facebook 用户公共(public)时间线?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18786031/