簡體   English   中英

如何從fbconnect feed對話框發布uiimage而不是圖像URL?

[英]How to post uiimage instead of image url from fbconnect feed dialog?

我需要發布uiimage(從應用程序截取的屏幕截圖)而不是URL,以便從Facebook對話框連同用戶選項一起在Facebook對話框中發布文本。 如何實現。 一些幫助表示贊賞。

通過fbconnect在Facebook中發布圖片,需要使用fbconnect api進行一些操作。

  1. 需要登錄facebook,然后檢查訪問密鑰和有效期。

  2. 如果那些不是零,那就去發布圖像,即

     NSData *imageData = UIImagePNGRepresentation(cellImageView.image); NSMutableDictionary *params = [[NSMutableDictionary alloc]initWithObjectsAndKeys:@"app name",@"message",imageData,@"source", nil]; [facebook requestWithGraphPath:@"me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self]; 

如果不是,則輸入訪問密鑰和到期密鑰,然后輸入上面寫的圖像郵政編碼。

有關更多下載,請查看fbconnect api並查看登錄信息,並查看帶有剎車點的代碼。

為此用戶需要登錄委托和fb請求委托。

也不要忘記使用應用程序ID初始化facebook obj並設置其委托人self。

您可以嘗試類似的方法來張貼照片部分。 我確定文字只是另一個領域。

@try {
     // make sure your permissions are set
     NSArray *permissions = [[NSArray alloc] initWithObjects:
     @"publish_stream",
     nil];

        [FBSession openActiveSessionWithPublishPermissions:permissions
                                           defaultAudience:FBSessionDefaultAudienceOnlyMe
                                              allowLoginUI:NO
                                         completionHandler:^(FBSession *session, FBSessionState state, NSError *error){
                                             NSLog(@"completion handler.");
                                         }];



        [FBRequestConnection startForUploadPhoto:imageToUpload
                               completionHandler:^(FBRequestConnection *connection, id result, NSError *error) {
                                   if (!error) {
                                       UIAlertView *tmp = [[UIAlertView alloc]
                                                           initWithTitle:@"Success"
                                                           message:@"Photo Uploaded!"
                                                           delegate:self
                                                           cancelButtonTitle:nil
                                                           otherButtonTitles:@"Ok", nil];

                                       [tmp show];
                                   } else {
                                       UIAlertView *tmp = [[UIAlertView alloc]
                                                           initWithTitle:@"Error"
                                                           message:@"Error uploading image to Facebook."
                                                           delegate:self
                                                           cancelButtonTitle:nil
                                                           otherButtonTitles:@"Ok", nil];

                                       [tmp show];

                                   }
                               }];

    }
    @catch (NSException *exception) {
        NSLog(@"-----> !! ERROR UPLOADING IMAGE TO FACEBOOK !!");
    }

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM