Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何使用储存在iPhone上的图像在facebook上发布墙贴?_Iphone_Facebook_Facebook Graph Api - Fatal编程技术网

如何使用储存在iPhone上的图像在facebook上发布墙贴?

如何使用储存在iPhone上的图像在facebook上发布墙贴?,iphone,facebook,facebook-graph-api,Iphone,Facebook,Facebook Graph Api,我有一个应用程序,我必须在facebook的墙上张贴图片。 现在的问题是我使用了GraphAPI facebook,我必须通过照片链接,但我的iPhone上有照片,而不是任何服务器上。 那么,如何在没有图像URL的情况下发布带有图像和其他参数的墙?编辑: - 事实上,在Facebook墙上张贴图片必须来自网络。所以你必须先上传图片;也许可以尝试第三方服务,如twitpic或其他,返回响应url并将其放置在您的参数中 - 您可以使用以下内容将图像发布到Facebook。您还可以用物理URL替换UI

我有一个应用程序,我必须在facebook的墙上张贴图片。 现在的问题是我使用了GraphAPI facebook,我必须通过照片链接,但我的iPhone上有照片,而不是任何服务器上。 那么,如何在没有图像URL的情况下发布带有图像和其他参数的墙?

编辑: -

事实上,在Facebook墙上张贴图片必须来自网络。所以你必须先上传图片;也许可以尝试第三方服务,如twitpic或其他,返回响应url并将其放置在您的参数中

-

您可以使用以下内容将图像发布到Facebook。您还可以用物理URL替换UIImage

NSMutableDictionary* params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                               kAppID, @"app_id",
                               @"http://bit.ly/dDZQXt", @"link",
                               @"www.has.to.be.web.based.com", @"picture",
                               EasyStrings(@"Mobile Profiles for ",device), @"name",
                               EasyStrings(@"Current Profile: ",currProfile), @"caption",
                               @"I am using Mobile Profiles for iPhone, iPod touch and iPad.", @"description",
                               message,  @"message",
                               nil];
[_facebook dialog:@"feed"
        andParams:params
      andDelegate:self];
它将是什么样子:
房屋图标是从[UIImage ImageName:@something.png]加载的。

您可以使用NSURLConnection作为HttpRequest库从url下载图像

You will have to do the following:
1. Create a NSUrlConnection and implement the delegate methods
2. Pass the url in your request and you will get the data in -(void)connectionDidFinishLoading: (NSURLConnection *)connection
3. You can then create a UIImage from this data using UIImage *image = [[UIImage alloc] initWithData:activeDownloadData];

我修改了facebook演示应用程序。它使用模式视图从手机中选择图片。您可以使用此代码,但必须添加两个按钮,即selectPicture按钮和uploadPhoto按钮-也请确保添加到.h文件中的UIViewController:

/**
 * Upload a photo.
 */
- (IBAction)uploadPhoto:(id)sender {

  NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                 image, @"picture",
                                 nil];

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

}

/**
 * Select a photo.
 */
- (void) imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary *)info
{
    image = [info objectForKey:UIImagePickerControllerOriginalImage];
    [self dismissModalViewControllerAnimated:YES];
}

- (void) imagePickerControllerDidCancel:(UIImagePickerController *)picker
{
    [self dismissModalViewControllerAnimated:YES];
}

- (IBAction) selectPicture:(UIButton *)sender;
{
    UIImagePickerController *picker = [[UIImagePickerController alloc] init];
    picker.delegate = self;
    [self presentModalViewController:picker animated:YES];
    [picker release];
}
试着使用我写的一个简单的库。这正是你想要的。上载一些本地图像,甚至为用户打开一个对话框,以便在用户的墙上添加注释:

BMFacebookPost *post = [[BMFacebookPost alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
[[BMSocialShare sharedInstance] facebookPublish:post];

可能重复:我的实际问题与所有这些不同…我知道如何在相册中上传照片,我知道如何做墙贴…但如何使用本地图像而不是URL(具有所有参数,如描述、链接、消息等)进行墙贴。。
BMFacebookPost *post = [[BMFacebookPost alloc] initWithImage:[UIImage imageNamed:@"image.png"]];
[[BMSocialShare sharedInstance] facebookPublish:post];