2012-01-23 97 views
0

由於Facebook SDK每個小時都會發生變化,因此很難獲得適用於當前SDK版本的實際教程..有些更改是激進的!iPhone Facebook SDK - 將照片從您的應用上傳到Facebook

我想上傳一張照片......但問題是我的FBSessionDelegate方法「fbDidLogin」永遠不會被調用。我登錄時,我們回到應用程序,但沒有發生:/

我想有一個與我的會議代表了一個問題:/

在這個新的SDK的主要變化是關於委派......你設定該委託曾經在視圖中加載而不是設置它[Facebook授權:權限委託:自我];

伊夫試圖與發現視頻(教程):http://developers.facebook.com/blog/post/532/

這是我.H

#import "Facebook.h" 

@interface sampleClass : UIViewController 
          <FBSessionDelegate, FBRequestDelegate> { 

    Facebook * facebook; 
} 

@property (strong, nonatomic) Facebook * facebook; 

- (IBAction)uploadPhoto:(id)sender; 

這是我.M

- (void)viewDidLoad { 
    [super viewDidLoad]; 

    facebook = [[Facebook alloc] initWithAppId:kAppId andDelegate:self]; 
} 

- (IBAction)uploadPhoto:(id)sender { 

    NSArray* permissions = [[NSArray alloc] initWithObjects: 
          @"offline_access", @"publish_stream", nil]; 

    [facebook authorize:permissions]; 

} 

#pragma mark - Facebook Session Delegate Methods 

- (void)fbDidLogin { 
    NSString *filePath = [[NSBundle mainBundle] pathForResource:@"sample" ofType:@"mov"]; 
    NSData *videoData = [NSData dataWithContentsOfFile:filePath]; 
    NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys: 
           videoData, @"video.mov", 
           @"video/quicktime", @"contentType", 
           @"Video Test Title", @"title", 
           @"Video Test Description", @"description", 
           nil]; 
    [facebook requestWithGraphPath:@"me/videos" 
        andParams:params 
       andHttpMethod:@"POST" 
        andDelegate:self]; 
} 

-(void)fbDidNotLogin:(BOOL)cancelled { 
NSLog(@"did not login"); 
} 


#pragma mark - Facebook Request Delegate Methods 

- (void)request:(FBRequest *)request didLoad:(id)result { 
if ([result isKindOfClass:[NSArray class]]) { 
    result = [result objectAtIndex:0]; 
} 
NSLog(@"Result of API call: %@", result); 
} 

- (void)request:(FBRequest *)request didFailWithError:(NSError *)error { 
    NSLog(@"Failed with error: %@", [error localizedDescription]); 
} 



#pragma mark - Support SSO for Facebook 


- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url { 
    return [self.facebook handleOpenURL:url]; 
} 

回答

0

你得到它的工作?你有沒有嘗試使用Hackbook作爲例子?以sdk下載爲例。這個鏈接指的是Demo App,但現在叫做Hackbook。 http://thinkdiff.net/facebook/how-to-develop-facebook-application-for-iphone/

密歇根州

+0

是的,我明白了!但我必須用另一種方式!現在我分享照片作爲應用程序的相冊,所以Facebook讓我上傳Facebook相冊上的照片,而不是共享一個「我可以做到這一點的文章」,但我將不得不上傳我的圖像在FTP上然後將圖像鏈接爲顯示圖片。明白嗎? :P – Marc

相關問題