有谁知道我如何使用 Sharekit 将视频发布到 Facebook?我应该自定义它还是已经有可以从 sharekit 做到这一点的东西?我可以下载任何扩展程序吗?

谢谢!

最佳答案

我建议不要使用 sharekit,而是为此使用 FBGraphAPI...

以下是您可以在 Facebook 上发布视频的以下步骤。

在 .h 文件中

#import "FbGraph.h"
#import "FbGraphFile.h"
#import "JSON.h"
#import <MobileCoreServices/MobileCoreServices.h>

@interface ViewController : UIViewController
{
    FbGraph                 *FB_Graph;
    FbGraphResponse         *FB_Graph_Response;
    FbGraphFile             *FB_Graph_File;
}

-(IBAction)btnShareVideoPress:(id)sender;

@end

在 .m 文件中调用此方法.....
- (void)viewDidAppear:(BOOL)animated
{
    [super viewDidAppear:animated];

    NSString *ClientID = @"197556430726736";

    FB_Graph = [[FbGraph alloc]initWithFbClientID:ClientID];

    [FB_Graph authenticateUserWithCallbackObject:self andSelector:@selector(fbGraphCallback:) andExtendedPermissions:@"user_photos,user_videos,publish_stream,offline_access,user_checkins,friends_checkins"];
}

-(IBAction)btnShareVideoPress:(id)sender
{
    NSString *path = [[NSBundle mainBundle] pathForResource:@"YouTubeTest" ofType:@"m4v"];
    NSURL *videoURL1=[NSURL fileURLWithPath:path];

    NSMutableDictionary *variables = [[NSMutableDictionary alloc]init];

    FB_Graph_File = [[[FbGraphFile alloc] initwithURL:videoURL1]retain];

    [variables setObject:FB_Graph_File forKey:@"file"];

    [variables setObject:@"Test video upload 1" forKey:@"message"];
    [variables setObject:@"video" forKey:@"MediaType"];
    [FB_Graph doGraphPost:@"me/videos" withPostVars:variables];

    FbGraphResponse *fb_graphresponse = [FB_Graph doGraphGet:@"me/videos/uploaded" withGetVars:variables];

    NSLog(@"postPictureButtonPressed:  %@", fb_graphresponse.htmlResponse);
}

关于iphone ShareKit 为 facebook 上传视频?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/6619769/

10-13 03:26