xcode 如何在 iphone 中实现 Facebook 集成的社交框架?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11698619/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to implement social framework for Facebook integration in iphone?
提问by iPhone_suren
I am working in a project where I need to get the friend's list of a person in Facebook. For that I need to implement social frameworkin my project. When i look for that framework I am getting share kit in all sites. Get share kit.Could you please tell me from where can I get that social framework. If possible provide me a sample code for implementing the above concept that I have mentioned.
我正在一个项目中工作,我需要在 Facebook 中获取某个人的朋友列表。为此,我需要在我的项目中实施社交框架。当我寻找该框架时,我在所有站点中都获得了共享工具包。 获取共享套件。你能告诉我从哪里可以得到那个社交框架。如果可能,请为我提供用于实现我提到的上述概念的示例代码。
Any Help will be appreciated
任何帮助将不胜感激
采纳答案by IronManGill
For implementing Facebook in your project use the latest FBGraph Method which is the latest from Facebook. You will have to import the FBGraph and the JSON parser first. Then add the following methods in the class you want to add the shareview :)
要在您的项目中实现 Facebook,请使用最新的 FBGraph 方法,这是 Facebook 的最新方法。您必须先导入 FBGraph 和 JSON 解析器。然后在要添加shareview的类中添加以下方法:)
Here's some code to help you along,
这里有一些代码可以帮助你,
-(void)buttonActionFb
{
//postFeedButton.hidden=NO;
NSString *client_id = @"130902823636657";
self.fbGraph =[[FbGraph alloc] initWithFbClientID:client_id];
[fbGraph authenticateUserWithCallbackObject:self andSelector:@selector(fbGraphCallback:) andExtendedPermissions:@"user_photos,user_videos,publish_stream,offline_access,user_checkins,friends_checkins"];
}
- (void)fbGraphCallback:(id)sender
{
if ((fbGraph.accessToken==nil)||([fbGraph.accessToken length]==0)) {
// NSLog(@"You pressed the 'cancel' or 'Dont Allow' button, you are NOT logged into Facebook...");
//resart authentication process...
[fbGraph authenticateUserWithCallbackObject:self andSelector:@selector(fbGraphCallback:) andExtendedPermissions:@"user_photos,user_videos,publish_stream,offline_access,user_checkins,friends_checkins"]; }
else
{
UIAlertView *alertfB=[[UIAlertView alloc] initWithTitle:@"Note" message:nil
delegate:self cancelButtonTitle:@"OK" otherButtonTitles: nil];
[alertfB show];
// NSLog(@"LOG IN FACEBBOK %@",fbGraph.accessToken);
}
}
回答by gaussblurinc
For Facebook you can use official facebook-ios-sdk(any version, but facebook makes release 3.0beta - more understandable and flexible than 2.0)
对于 Facebook,您可以使用官方facebook-ios-sdk(任何版本,但 facebook 发布 3.0beta - 比 2.0 更易于理解和灵活)
After that, it is good to read samples and other things.
之后,最好阅读样本和其他东西。
And you need to download sdk from github. - it is simple, too.
并且你需要从 github 下载 sdk。——也很简单。
回答by Waseem Shah
firstly you just login with your Facebook/twitter account and then on button click (where you want to share the data on Facebook or twitter ) and write this code
首先,您只需使用您的 Facebook/twitter 帐户登录,然后单击按钮(您想在 Facebook 或 twitter 上共享数据的位置)并编写此代码
NSArray *activityItems;
activityItems = @[@"Text Here",self.imgview.image];
UIActivityViewController *activityController =
[[UIActivityViewController alloc]
initWithActivityItems:activityItems
applicationActivities:nil];
[self presentViewController:activityController
animated:YES completion:nil];
imgview is the UIimageView outlet and this simply share your text and image on the Facebook/Twitter ;-) i think this is help you
imgview 是 UIimageView 插座,这只是在 Facebook/Twitter 上分享您的文本和图像;-) 我认为这对您有帮助
回答by Jorge
Integrated with IOS 6 there are interfaces that allows you to post to FB without importing any external framework, in the same way that you used to present a mail interface, More info at : http://developer.apple.com/library/ios/#documentation/Social/Reference/Social_Framework/_index.html#//apple_ref/doc/uid/TP40012233
与 IOS 6 集成的接口允许您在不导入任何外部框架的情况下发布到 FB,就像您用来呈现邮件界面的方式一样,更多信息请访问:http: //developer.apple.com/library/ios /#documentation/Social/Reference/Social_Framework/_index.html#//apple_ref/doc/uid/TP40012233
回答by Rickye
Social Framework is actually under NDA, so if you aren't a registered Developer, you can't get that.
Social Framework 实际上是在 NDA 之下,所以如果你不是注册开发者,你就不能得到它。