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

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

问题描述

我正在尝试向我的应用程序的Facebook粉丝页面和用户墙壁发布照片。
我已经成功地将照片发布在用户墙上,但未能将其张贴在粉丝页面的墙壁上。 ()用户不一定是管理员或页面所有者,只是普通用户。由于粉丝页面有任何人可以发布的选项,用户首先不需要这样的页面强制。



googling一段时间后,我发现这个答案。根据它,我需要一个access_token的粉丝页面和一个album_id这样做。但是我找不到任何关于如何获得他们的线索。到目前为止,我已经尝试过这个代码:

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

[appDelegate.facebook requestWithGraphPath:@me / photos
andParams:params
andHttpMethod:@POST
andDelegate:self]; //发布在用户墙上,工作正常

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:@POSTandDelegate:self]; //发布在粉丝页面墙上,这不起作用
}

任何人帮我这个吗我在这里缺少什么?感谢提前。



更新



根据此答案,普通用户无法将照片发布到iOS应用程式的粉丝专页墙壁,但可以在其上分享照片。现在,我的问题是,如何完成在用户墙上发布照片,并在同一时间在粉丝页面墙上分享?可能吗?如何在粉丝页面墙上分享照片?



更新2



这个答案和问题表示,普通用户可以通过新闻Feed发布到粉丝页面墙壁,所以我修改了代码如下:

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

}

但是,我不断得到这个可笑的错误消息和应用程序崩溃:

   -  [UIImage length]:无法识别的选择器发送到实例0x24d110 
2012-06-06 19:59 :03.114 app_name [2739:707] ***由于未捕获的异常'NSInvalidArgumentException'终止应用程序,原因:' - [UIImage length]:无法识别的选择器发送到实例0x24d110'
pre>

我现在该怎么办?



在等待这么久之后,问题在我脑海里,这是甚么可能吗?如果是这样,我该如何完成这个任务?如果没有,那么什么是替代品?请帮助。



更新3



只是发现那里是iOS sdk和javascript sdk中的已知错误,用于在粉丝页面墙上发布对话框。图像上传也是这样吗?如果有人有解决方案来避免这个错误,请帮忙。

解决方案

目前还没有(2012年6月)由于API中的错误: https://developers.facebook.com/bugs/206254392780441 具有



一个解决方法是发布到页面的 / feed 连接,并将图像附加到Feed故事。该图像不会像正确的照片上传一样大,但应该可以正常工作。



该错误意味着发布到 / PAGE_ID /照片使用用户 access_token 连接页面将错误地将照片上传到用户的 /照片连接。



使用页面的 access_token发布到页面的 /照片连接将按预期工作;照片将显示在页面的照片页面上,页面的时间轴上,并归因于页面本身(即从页面)



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


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?)

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.

UPDATE

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?

UPDATE 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'

What should I do now?

At this point after waiting so long, the question comes in my mind is, is this even possible? If so, how do I accomplish this task? And if not, then what are the alternatives? Please help.

Update 3

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.

解决方案

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

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.

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.

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)

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天全站免登陆