0
我是StackOverflow和iOS的新手。我试图获取用户信息,如团体,书籍等,我需要使用Facebook图形API。要使用图形API,您必须使用访问令牌。我在Facebook开发者页面上阅读了关于这个主题的文章,并且我编写了一些代码,但它没有用。你可以帮我吗?我的代码是正确的还是应该用另一种方式?我无法使用Facebook访问令牌在iOS上使用图形API
我的.h文件:
#import <UIKit/UIKit.h>
#import "FBConnect.h"
@interface FirstViewController : UIViewController <FBSessionDelegate,FBLoginDialogDelegate,FBRequestDelegate>{
Facebook *face;
}
@property(nonatomic,retain)Facebook *face;
-(IBAction)facePushed:(id)sender;
-(IBAction)logoutPushed:(id)sender;
我.m文件:
-(IBAction)facePushed:(id)sender{
NSLog(@"FacePushed Began");
face=[[Facebook alloc]initWithAppId:@"313714785358239" andDelegate:self];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
if ([defaults objectForKey:@"FBAccessTokenKey"]
&& [defaults objectForKey:@"FBExpirationDateKey"]) {
face.accessToken = [defaults objectForKey:@"FBAccessTokenKey"];
face.expirationDate = [defaults objectForKey:@"FBExpirationDateKey"];
}
if (![face isSessionValid]) {
[face authorize:nil ];
}
else {
NSLog(@"Session is valid");
}
NSLog(@"FacePushed End");
}
}
- (void)fbDidLogin {
NSLog(@"aslan");
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
[defaults setObject:[face accessToken] forKey:@"FBAccessTokenKey"];
[defaults setObject:[face expirationDate] forKey:@"FBExpirationDateKey"];
NSLog(@"%@", [face accessToken]);
[defaults synchronize];
}
- (void)fbDialogLogin:(NSString *)token expirationDate:(NSDate *)expirationDate {
NSLog(@"%@",token);
}
它没有解决我的问题..但我改善了我的code.thanks。 mycode不使用delegetes我不能看到我的nslogs。 – yatanadam 2012-03-13 15:44:04
单击facePush按钮时发生了什么? – 2012-03-13 15:45:29
我把2个更多的nslog我的代码第一个是开始facepushed第二个结束了facepushed。当我推开脸,我看到了我的新nslogs。别的。并打开脸登录页面,并说这个应用程序想使用喜欢等允许或不我点击允许。只是。 – yatanadam 2012-03-13 15:57:56