簡體   English   中英

在facebook上傳圖片

[英]uploading image in facebook

在Facebook牆中上傳圖像時,圖像根本不會出現在牆上。 我試過了:

[[FBRequest requestWithDelegate:self] call:@"facebook.Users.setStatus" params:
            params dataParam:UIImagePNGRepresentation(img)];

無濟於事。

您可以使用Sharekit...。

試試這個代碼...

 -(void)shareOnFacebook {   
        //take screenshot
           UIImage *image = "Your image";

       //for debug purpose the image can be stored to photo album
       //UIImageWriteToSavedPhotosAlbum(image, nil, nil, nil);

         SHKItem *fbItem = [SHKItem image:image title:@"Check out my Image!"];
        [SHKFacebook shareItem:fbItem];
    }

使用sharekit可以嘗試以下代碼:

-(IBAction)btnSendToFacebookPressed:(id)sender
{
            NSString *var = [[NSUserDefaults standardUserDefaults] valueForKey:@"IMAGE_INDEX"];//This line may not be useful to you...

            NSString *imageIndex = [[NSBundle mainBundle] pathForResource:var ofType:@"jpg"];

            SHKItem *item = [SHKItem image:[UIImage imageWithContentsOfFile:imageIndex] title:@"Your Title"];
            [NSClassFromString(@"SHKFacebook") performSelector:@selector(shareItem:) withObject:item];

 }

嘗試使用Sharekit做到這一點。

將Sharekit框架添加到您的項目。

從shkconfig.h文件更改設置。

傳遞可以從facebook-> developer-> apps-> create new app-> generate keys生成的密鑰,將其傳遞給shkconfig.h

-(IBAction) tryItOnFb:(id)sender
{

     SHKItem *item = [SHKItem image:[UIImage imageNamed:@"YES.png"]title:@"FB Test"];
     [NSClassFromString(@"SHKFacebook") performSelector:@selector(shareItem:) withObject:item];
}

圖像將進入您的相冊,並在牆上顯示有關此相冊的信息。

NSMutableDictionary *params =[NSMutableDictionary dictionaryWithObjectsAndKeys:@"Testmessage", @"message", imageData, @"picture", nil];

[facebook requestWithGraphPath:@"/me/photos" andParams:params andHttpMethod:@"POST" andDelegate:self];

暫無
暫無

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

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