3
我的iOS應用程序詢問用戶「publish_stream」的權限,問題是當可選的權限屏幕出現,用戶點擊允許非Facebook的SDK不採取這一行動,因爲應用程序可以發佈在用戶牆上。當我檢查Facebook帳戶上的設置時,我發現存在「以您的名義發佈」權限。這裏是代碼:Facebook IOS SDK可選權限
-(void)loginToFacebook
{
[facebook authorize:permissions];}
- (void)fbDidLogin
{
NSLog(@"did login");
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[facebookAgent accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[facebookAgent expirationDate] forKey:@"FBExpirationDateKey"];
[defaults synchronize];
[facebook requestWithGraphPath:@"me/permissions" andDelegate:self];
}
- (void)request:(FBRequest *)request didLoad:(id)result
{
NSLog(@"%@",result);
}
如果用戶點擊允許在可選權限頁面的搜索結果中要求非:didLoad方法是:
{
data = (
{
"create_note" = 1;
email = 1;
installed = 1;
"photo_upload" = 1;
"publish_actions" = 1;
"publish_stream" = 1;
"share_item" = 1;
"status_update" = 1;
"user_birthday" = 1;
"user_hometown" = 1;
"user_location" = 1;
"user_relationships" = 1;
"video_upload" = 1;
}
);
}
,這是郵編:
-(void)publishToFacebook
{
NSDictionary* attachment = [NSDictionary dictionaryWithObjectsAndKeys:
@"Name", @"name",
@"Caption", @"caption",
@"Message", @"message",
@"http://url...", @"link",
@"http://imageUrl...", @"picture", nil];
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithDictionary:attachment];
[facebook requestWithGraphPath:@"me/feed"
andParams:params
andHttpMethod:@"POST"
andDelegate:self];
}
* sidenote *:上述代碼不再適用於Facebook iOS SDK 3.x – Raptor