2013-04-30 24 views
3

我们可以使用facebook图表api更改Facebook应用程序邀请文本吗?可以使用图表api更改Facebook应用程序邀请文本

通常这有格式 - “邀请者名称发送给你一个请求”,我们可以将这个文本替换为我们自己的吗?

(这得到显示为FB墙上的通知。)

我使用下面的代码 -

- (void)load:(BOOL)NeedToSendAppRequest AndMessage:(NSString*)message AndFriendID:(NSString*)friendID { 

    NSString *urlString = nil; 
    isNeedToSendAppRequest = NeedToSendAppRequest; 

    if (NeedToSendAppRequest) { 
     NSString *redirectUrlString = FACEBOOK_REDIRECT_URL; 
     NSString *authFormatString = @"https://m.facebook.com/dialog/apprequests?app_id=%@&target_url=fb%@&to=%@&message=%@&redirect_uri=%@"; 
     urlString = [NSString stringWithFormat:authFormatString, _apiKey, _apiKey,friendID,message,redirectUrlString]; 
    }else{ 
     NSString *redirectUrlString = @"http://www.facebook.com/connect/login_success.html"; 
     NSString *authFormatString = @"https://graph.facebook.com/oauth/authorize?client_id=%@&redirect_uri=%@&scope=%@&type=user_agent&display=touch"; 
     urlString = [NSString stringWithFormat:authFormatString, _apiKey, redirectUrlString, _requestedPermissions]; 
    } 

    NSURL *url = [NSURL URLWithString:urlString]; 
    NSURLRequest *request = [NSURLRequest requestWithURL:url]; 
    [_webView loadRequest:request]; 

} 

回答

-1

看看下面的样本 - friendToInviteCSVString是逗号分隔的朋友FB的ID字符串你想邀请。您可以在参数字典的message键中设置自定义邀请消息。

这是用3.X FB的iOS SDK,顺便说一句:

//Remove last comma from CSV string 
friendToInviteCSVString = [friendToInviteCSVString stringByTrimmingCharactersInSet:[NSCharacterSet punctuationCharacterSet]]; 

NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
              NSLocalizedString(@"Check out this awesome app.", @"Check out this awesome app."), @"message", 
              friendToInviteCSVString, @"to", nil]; 



//Do FB invites 
DDLogVerbose(@"Active fb session: %@", [FBSession activeSession]); 

[FBWebDialogs presentDialogModallyWithSession:[FBSession activeSession] dialog:@"apprequests" parameters:parameters handler:^(FBWebDialogResult result, NSURL *resultURL, NSError *error) 
{ 
     DDLogVerbose(@"Facebook closed dialog with result: %d, URL: %@, error: %@", result, resultURL, error); 
}]; 

编辑:

好了,所以我去了我的遗留代码周围挖,这里是使用FBDialog的样本是您正在使用的SDK版本中有什么。首先你需要一个Facebook对象:

Facebook *facebook = [[Facebook alloc] initWithAppId:kFBAppID andDelegate:self]; 

//Check if token is valid 
if (FBSession.activeSession.accessToken) 
{ 
    DLog(@"Init FB with activeSession, token: %@ and expirationDate: %@", FBSession.activeSession.accessToken, FBSession.activeSession.expirationDate); 

    self.facebook.accessToken = FBSession.activeSession.accessToken; 
    self.facebook.expirationDate = FBSession.activeSession.expirationDate; 
} 
else 
{ 
    //No FB Token, do something here - ask user for permission, etc 
} 

NSMutableDictionary *parameters = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
            NSLocalizedString(@"Check out this awesome app.", @"Facebook apprequest invite message"), @"message", friendsToInvite, @"to", nil]; 

[self.facebook dialog:@"apprequests" andParams:parameters andDelegate:self]; 
+0

感谢您的帮助JAI govindani .. :)但对图形API为同一会更有帮助,因为我的应用程序已基本完成,我不能改变FB SDK这个任何想法时间。 – Richa 2013-05-01 06:40:03

+0

因此,您使用的是SDK之前的3.x版本? – 2013-05-01 06:44:39

+0

我用这个链接的类: - https://github.com/megastep/facebook-iphone-sdk/blob/master/src/FBDialog.m – Richa 2013-05-01 07:49:11

相关问题