Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
895 views
in Technique[技术] by (71.8m points)

iphone ShareKit with Video upload for facebook?

Does anyone know how i can use Sharekit to post a video to facebook? Should i customize it or is there something already out there that can do this from sharekit? Any extensions i can download?

Thanks!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Instead of using the sharekit i suggest to use FBGraphAPI for this...

Here are the following steps, that you can post video on Facebook..

in .h file

#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

in .m file call this method.....

- (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);
}

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...