我知道如何喜欢Facebook中的照片/评论。但我想通过我的应用程序喜欢Facebook 页面。可能吗?如果是的话,任何人都可以给我一些建议吗?像在iOS中的Facebook页面
2
A
回答
3
这是一个问题。如果你能够做到这一点,你将能够以编程方式“喜欢”一个页面,而用户不必知道这是发生了什么。这将违反Facebook的TOS。
我认为只需在应用程序中放置一个常规的“喜欢的按钮”,并让用户决定是否要点击该按钮,会更好。
一些相关的帖子 -
1
我写了一个方法,我的电话,您可以通过给它的URL喜欢你的页面在该方法中。 对于这种方法,你必须使用Facebook的SDK,并需要添加一些不赞成的Facebook文件。
#import "Facebook.h"
#import "FBCustomLoginDialog.h"
#import "Accounts/Accounts.h"
它是由你介绍如何找到文件,并使用it.Any的方式,这是工作的代码像页。
-(void)like
{
NSString *[email protected]"http://in.yahoo.com/?p=us"; // here you page url
NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
likePage, @"object",[[NSUserDefaults standardUserDefaults] valueForKey:@"token"],@"access_token",
nil];
[FBRequestConnection startWithGraphPath:@"/me/og.likes" parameters:params HTTPMethod:@"POST" completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
UIAlertView *alert=[[UIAlertView alloc] initWithTitle:nil message:[NSString stringWithFormat:@"liked with id %@",[result valueForKey:@"id"]] delegate:nil cancelButtonTitle:@"Ok" otherButtonTitles:nil];
[alert show];
NSLog(@"result is %@",result);
}];
}
- (IBAction)likepageonFB:(id)sender
{
if ([[FBSession activeSession] isOpen]) {
[self like];
}else
{
[appDelegate openSession];
}
}
这里是在应用程序委托文件中使用的代码....
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
// Override point for customization after application launch.
self.viewController = [[LikeAppViewController alloc] initWithNibName:@"LikeAppViewController" bundle:nil];
self.window.rootViewController = self.viewController;
[self.window makeKeyAndVisible];
if (FBSession.activeSession.state == FBSessionStateCreatedTokenLoaded) {
// To-do, show logged in view
// [self openSession];
} else {
// No, display the login page.
[self showLoginView];
}
return YES;
}
#pragma mark- Facebook Methods
- (void)sessionStateChanged:(FBSession *)session
state:(FBSessionState) state
error:(NSError *)error
{
switch (state) {
case FBSessionStateOpen:
{
[[NSUserDefaults standardUserDefaults] setValue:[[FBSession activeSession] accessToken] forKey:@"token"];
NSLog(@"token is %@",[[FBSession activeSession] accessToken]);
[self.viewController like];
}
break;
case FBSessionStateClosed:
case FBSessionStateClosedLoginFailed:
[self showLoginView];
break;
default:
break;
}
if (error) {
UIAlertView *alertView = [[UIAlertView alloc]
initWithTitle:@"Error"
message:error.localizedDescription
delegate:nil
cancelButtonTitle:@"OK"
otherButtonTitles:nil];
[alertView show];
}
}
- (void)openSession
{
NSLog(@"open session called ");
NSArray *permissions=[[NSArray alloc] initWithObjects:@"publish_stream",@"publish_actions",@"user_likes",@"user_about_me",nil];
[FBSession openActiveSessionWithPublishPermissions:permissions defaultAudience:FBSessionDefaultAudienceEveryone allowLoginUI:YES completionHandler:^(FBSession *session,
FBSessionState state, NSError *error) {
[self sessionStateChanged:session state:state error:error];
}];
}
- (void)showLoginView
{
[self.viewController presentedViewController];
}
- (BOOL)application:(UIApplication *)application
openURL:(NSURL *)url
sourceApplication:(NSString *)sourceApplication
annotation:(id)annotation
{
return [FBSession.activeSession handleOpenURL:url];
}
- (void)fbDialogLogin:(NSString*)token expirationDate:(NSDate*)expirationDate
{
NSLog(@"expiry date is %@",expirationDate);
}
1
Fb的比如Widget可以嵌入到我们的应用程序。你只需要添加一个webView并获得Fb Like Widget html code/URL here。
在ViewController.h要添加FB像按钮:
在TestViewController.m#import "AboutUsViewController.h"
@implementation AboutUsViewController
@synthesize fbLikeWebView = _fbLikeWebView;
- (void)viewDidLoad
{
[super viewDidLoad];
//Add this code for FbLike Webview
self.fbLikeWebView = [[UIWebView alloc] initWithFrame: CGRectMake(100.0, 50.0, 55.0, 70.0)];
_fbLikeWebView.opaque = NO;
_fbLikeWebView.backgroundColor = [UIColor clearColor];
_fbLikeWebView.delegate = self;
[self.view addSubview:_fbLikeWebView];
for (UIScrollView *subview in _fbLikeWebView.subviews)
{
if ([subview isKindOfClass:[UIScrollView class]]) {
subview.scrollEnabled = NO;
subview.bounces = NO;
}
}
}
#import <UIKit/UIKit.h>
@interface TestViewController : UIViewController <UIWebViewDelegate>
@property (strong, nonatomic) UIWebView * fbLikeWebView;
-(void)embedFBLikeButton;
@end
然后在viewWillAppear中方法调用enbeddFBLikeButton方法添加的Wigdet的fbLike按钮网页视图:
-(void)viewWillAppear:(BOOL)animated
{
[self embedFBLikeButton];
[_fbLikeWebView reload];
}
-(void)embedFBLikeButton
{
NSString *facebookUrl = //here paste the url you get from fb developer link above;
[self.fbLikeWebView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:facebookUrl]]];
}
您符合UIWebViewDelegate no w ^轮到它定义日在这里edelegate方法:
#pragma mark - WebView Delgate Methods
- (BOOL)webView:(UIWebView *)webview shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType
{
if ([request.URL.lastPathComponent isEqualToString:@"login.php"])
{
[self login];
return NO;
}
return YES;
}
-(void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error
{
[_fbLikeWebView stopLoading];
}
这种方法登录用户的Facebook帐户:
- (void)login
{
[FBSession setActiveSession: [[FBSession alloc] initWithPermissions:@[@"publish_actions", @"publish_stream", @"user_photos"]]];
[[FBSession activeSession] openWithBehavior: FBSessionLoginBehaviorForcingWebView completionHandler:^(FBSession *session, FBSessionState status, NSError *error) {
switch (status) {
case FBSessionStateOpen:
// call the legacy session delegate
//Now the session is open do corresponding UI changes
if (session.isOpen) {
FBRequest *me = [FBRequest requestForMe];
[me startWithCompletionHandler: ^(FBRequestConnection *connection,
NSDictionary<FBGraphUser> *my,
NSError *error) {
if (!my) {
NSLog(@"Facebook error:\n%@", error.description);
[[[UIAlertView alloc] initWithTitle: @"Error"
message: @"Facebook Login error."
delegate: self
cancelButtonTitle: @"Ok"
otherButtonTitles: nil, nil] show];
return;
}
}];
[_fbLikeWebView reload];
[[[UIAlertView alloc] initWithTitle: @""
message: @"Successfully Login. Please click on like button"
delegate: self
cancelButtonTitle: @"Ok"
otherButtonTitles: nil, nil] show];
}
break;
case FBSessionStateClosedLoginFailed:
{
[_fbLikeWebView reload];
}
break;
default:
break; // so we do nothing in response to those state transitions
}
}];
}
相关问题
- 1. 像iOS中的Facebook页面
- 2. 嵌入Facebook页面中的iOS应用
- 3. 更改Facebook中的图像“贴到墙上”页面iOS
- 4. Facebook,IOS和商业页面
- 5. 页面重定向像在Facebook中
- 6. 在Facebook上显示像/不像页面
- 7. 像Facebook一样的Facebook页面 - 弃用?
- 8. 像Facebook页面和显示页面墙
- 9. 在Facebook iOS SDK 3.5.x中获取Facebook页面访问令牌
- 10. Facebook页面就像数
- 11. 像Facebook页面编程式
- 12. 不像Facebook页面API
- 13. iOS,如何喜欢Facebook上的页面?
- 14. 在UINavigationController中滑回像iOS中的Facebook
- 15. 如何在iOS的FBSDK中标记Facebook页面
- 16. Facebook页面在ios应用程序中的相册
- 17. 如何在iOS Facebook上加载Facebook页面链接应用
- 18. 发布图片到Facebook页面,iOS
- 19. 的Facebook就像一个页面
- 20. 从Android到Facebook页面的图像
- 21. Facebook的页面/饲料丢失图像
- 22. Facebook的注册和像页面
- 23. 动态的JSP页面像facebook
- 24. 像Facebook页面上的帖子
- 25. facebook - 像通过API的页面
- 26. ios sdk facebook图形api,无法将图像发布到Facebook页面
- 27. 使用Facebook iOS SDK的私人讯息Facebook页面?
- 28. 使用IOS上的Facebook应用程序打开Facebook组页面
- 29. 打开Facebook页面进入Facebook应用程序的ios +离子
- 30. 在IOS应用程序中显示Facebook页面订阅源
我们可以使用图形API来programmaatically喜欢一个Facebook网页编写代码。 – 2013-12-31 10:15:51
@AbdulYasin - 随时添加你自己的答案。我仍然认为这是不可能的。检出我发布的链接 - 它们都包含相关信息。 – Lix 2013-12-31 10:20:44
- 我查了很多。最后得出的结论是,Facebook不会允许我们在未经用户事先许可的情况下喜欢网页。 非常感谢你Lix ... 那么,什么是喜欢公共页面的完美方法。 期待收到你的来信。 – 2014-01-02 08:13:23