share an image on FB wall

前端 未结 3 611
广开言路
广开言路 2021-01-07 14:52

I have an image in my app which I want to share on FB.

Now I have FB app installed on my iPhone.

What I want is when I tap on share in the image of my app th

相关标签:
3条回答
  • 2021-01-07 15:38

    https://github.com/ShareKit/ShareKit

    Try using sharekit it is useful.. Follow all the step and if there is and query than post back

    0 讨论(0)
  • 2021-01-07 15:41

    read these tutorial to share an image on Facebook

    http://www.capturetheconversation.com/technology/iphone-facebook-oauth-2-0-and-the-graph-api-a-tutorial-part-2
    http://www.raywenderlich.com/1488/how-to-use-facebooks-new-graph-api-from-your-iphone-app,
    http://www.raywenderlich.com/1626/how-to-post-to-a-users-wall-upload-photos-and-add-a-like-button-from-your-iphone-app

    0 讨论(0)
  • 2021-01-07 15:49

    add FBConnect into your project and use below code for share capture image on facebook. Also add delegate FBSessionDelegate, FBDialogDelegate, FBRequestDelegate into your .h file. If you want to share local image than you don't need to upload image on server. pass uiimage object into facebook params.

    if (facebook == nil) {
            facebook = [[Facebook alloc] initWithAppId:@"your facebook key "];
    
    
        }   
    
    
        NSArray* permissions =  [NSArray arrayWithObjects:
                                 @"publish_stream", @"offline_access", nil] ;
        //  
        [facebook authorize:permissions delegate:self];
    
    - (BOOL) takeScreenshot
    {
        UIGraphicsBeginImageContext(self.view.frame.size);
        [self.view.layer renderInContext:UIGraphicsGetCurrentContext()];
        UIImage *viewImage = UIGraphicsGetImageFromCurrentImageContext();
        UIGraphicsEndImageContext();
        UIImageWriteToSavedPhotosAlbum(viewImage, nil, nil, nil);
    
    
    
        NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       viewImage,@"message",                                   
                                       nil];
    
        [facebook requestWithGraphPath:@"me/photos"   // or use page ID instead of 'me'
                             andParams:params
                         andHttpMethod:@"POST"
                           andDelegate:self];
    
    
    
        return YES;
    }
    
    
    #pragma mark -
    #pragma mark FBSessionDelegate
    /**
     * Called when the user has logged in successfully.
     */
    - (void)fbDidLogin {
        isFBLogged = YES;   
        [self takeScreenshot];
    
        if([self takeScreenshot])
        {
            UIAlertView *alert = [[UIAlertView alloc]
                                  initWithTitle: @"Image share sucessfully"
                                  message: nil
                                  delegate: nil
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
            [alert show];
            [alert release];
        }
        else
        {
            UIAlertView *alert = [[UIAlertView alloc]
                                  initWithTitle: @"Image share unsucessfully"
                                  message: nil
                                  delegate: nil
                                  cancelButtonTitle:@"OK"
                                  otherButtonTitles:nil];
            [alert show];
            [alert release];
        }
    
    
    }
    
    0 讨论(0)
提交回复
热议问题