普通非管理员用户通过 iOS 应用将照片发布到 Facebook 粉丝页面 [英] Posting Photo to facebook fan page via iOS app by regular non-admin users

查看:22
本文介绍了普通非管理员用户通过 iOS 应用将照片发布到 Facebook 粉丝页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将照片发布到我的应用程序 Facebook 粉丝页面和用户墙上.我已经成功在用户墙上发布了照片,但在粉丝页面墙中发布失败.(用户不一定是管理员或页面所有者,只是普通用户.由于粉丝页面具有任何人都可以发布的选项,因此用户甚至不必先喜欢页面.对吧?)

I am trying to post a photo to my apps facebook fan page and to the users wall also. I have been successful to post the photo on the users wall, but failed to post it in the fan pages wall. (The user is not necessarily an admin or page owner, just the regular users. As the fan page has the option of anyone can post to it, it is not mandatory for the user to even like the page first. Right?)

谷歌搜索一段时间后,我找到了这个答案.根据它,我需要粉丝页面的 access_token 和专辑 ID 才能这样做.但我找不到任何关于如何获得它们的线索.到目前为止,我已经尝试过这段代码:

After googling a while, I found this answer. According to it, I need an access_token of the fan page and an album_id to do so. But I can't find any clue about how to get them. So far I have tried this code:

if ([appDelegate.facebook isSessionValid]) 
    {
        NSMutableDictionary *params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       resultImage, @"picture",
                                       nil];

        [appDelegate.facebook requestWithGraphPath:@"me/photos"
                                         andParams:params
                                     andHttpMethod:@"POST"
                                       andDelegate:self]; // to post on users wall, works fine

         NSString *path = [NSString stringWithFormat:@"my/accounts /fan_page_id?fields=access_toke/photos"];
        [appDelegate.facebook setAccessToken: FACEBOOK_ACCESS_TOKEN];

        [appDelegate.facebook requestWithGraphPath:path andParams:params andHttpMethod:@"POST" andDelegate:self]; // to post on fan page wall,  this doesn't work
    }

谁能帮我解决这个问题?我在这里错过了什么?提前致谢.

Can anyone help me with this? What am I missing here? Thanks in advance.

更新

根据这个答案,普通用户无法通过 iOS 应用将照片发布到粉丝页面墙,但是可以在上面分享照片.现在,我的问题是,如何完成将照片发布到用户墙上并同时在粉丝页面墙上共享?是否可以?如何在粉丝专页墙上分享照片?

According to this answer, a regular user can not post a photo to the fan pages wall from an iOS app but can share the photo on it. Now, my question is, how do I accomplish posting the photo on the users wall and share it on the fan page wall at the same time? Is it possible? How do I share the photo on the fan page wall?

更新 2

这个答案和问题 说普通用户可以通过新闻提要发布到粉丝页面墙,所以我像这样修改我的代码:

This answer and the question says that the regular users can post to a fan page wall via news feed, so i modified my code like this:

if ([appDelegate.facebook isSessionValid]) {
        NSMutableDictionary *page_params = [NSMutableDictionary dictionaryWithObjectsAndKeys:
                                       @"fan_page_id", @"to",
                                       @"Test", @"name",
                                       @"Test", @"caption",
                                       resultImage, @"picture",
                                       nil];
        [appDelegate.facebook   dialog:@"feed"
                                andParams:page_params
                                andDelegate:self];

}

但是,我不断收到这个荒谬的错误消息,应用程序崩溃了:

But, I keep getting this ridiculous error message and the app crashes:

-[UIImage length]: unrecognized selector sent to instance 0x24d110
2012-06-06 19:59:03.114 app_name[2739:707] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[UIImage length]: unrecognized selector sent to instance 0x24d110'

我现在该怎么办?

等了这么久,现在我的脑海里出现了一个问题,这可能吗?如果是这样,我该如何完成这项任务?如果不是,那么有哪些替代方案?请帮忙.

更新 3

刚刚发现 iOS sdk 和 javascript sdk 中都有一个已知错误在粉丝页面墙上张贴对话.图片上传也是这样吗?如果有人有避免此错误的解决方案,请提供帮助.

Just found that there is a known bug in both iOS sdk and the javascript sdk for posting dialogs in fan page wall. Is this true for image upload too? If anyone has a solution to avoid this bug, please help.

推荐答案

由于 API 中的错误,目前(2012 年 6 月)无法实现:https://developers.facebook.com/bugs/206254392780441 有详细信息.

This isn't currently (June 2012) possible because of a bug in the API: https://developers.facebook.com/bugs/206254392780441 has the details.

一种解决方法是发布到页面的 /feed 连接并将图像附加到提要故事.该图片不会显示为正常上传的照片那么大,但应该可以正常工作.

One workaround is to post to the /feed connection of the page and attach an image to the feed story. That image won't be displayed as large as a proper photo upload, but should work OK.

该错误意味着使用用户 access_token 发布到主页的 /PAGE_ID/photos 连接会错误地将照片上传到用户的 /photos 连接代替.

That bug means that posting to the /PAGE_ID/photos connection of a Page using a User access_token will incorrectly upload the photo to the user's /photos connection instead.

在使用页面的access_token 时,发布到页面的/photos 连接将按预期工作;照片将出现在页面的照片页面、页面的时间轴上,并归因于页面本身(即来自"页面)

Posting to a page's /photos connection will work as expected when using the Page's access_token; the photo will appear on the page's photos page, on the page's timeline, and attributed to the Page itself (i.e 'from' the page)

如果您的应用专门用于向页面添加内容,并且具有服务器端组件,则另一种将用户照片放到页面上的解决方法是让用户通过您自己的界面向您提供照片(即将其从用户的设备上传到您的服务器),并使用其中一个页面管理员的 access_tokens 获取 页面 access_token 并以这种方式上传.

If your app is specifically for adding content to a page, and has a server-side component, another workaround to get the photos from a user onto the page is to have the users supply a photo to you via your own interface (i.e upload it from the user's device to your server), and use one of the page admins' access_tokens to get a Page access_token and make the upload that way.

这篇关于普通非管理员用户通过 iOS 应用将照片发布到 Facebook 粉丝页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆