iPhone Facebook Video Upload

前端 未结 5 1449
[愿得一人]
[愿得一人] 2020-12-01 03:35

I\'ve been working on this for a couple of days now and just can\'t seem to find a straight answer or example anywhere. I am trying to upload a video to facebook from within

5条回答
  •  长情又很酷
    2020-12-01 03:53

    - (void)viewDidLoad
    {
        facebook = [[Facebook alloc] initWithAppId:@"276907032339239"];
    }
    
    - (void)viewDidUnload
    {
        [super viewDidUnload];
        // Release any retained subviews of the main view.
        // e.g. self.myOutlet = nil;
    }
    - (BOOL)shouldAutorotateToInterfaceOrientation:(UIInterfaceOrientation)interfaceOrientation
    {
        // Return YES for supported orientations
        return (interfaceOrientation == UIInterfaceOrientationPortrait);
    }
    - (IBAction)buttonClicked:(id)sender
    {
        NSArray* permissions = [[NSArray alloc] initWithObjects:
                                @"publish_stream", nil];
        [facebook authorize:permissions delegate:self];
        [permissions release];
    }
    - (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];
        NSLog(@"hiiiiiiiii");
    
    }
    
    -(void)fbDidNotLogin:(BOOL)cancelled 
    {
    
        NSLog(@"did not login");
    
    }
    
    - (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]);
    }
    

提交回复
热议问题