简体   繁体   English

通过Graph API将照片发布到Facebook:OAuthException:(#100)param标签必须是一个数组

[英]Publishing photo to Facebook via Graph API: OAuthException: (#100) param tags must be an array

I'm attempting to upload a photo to Facebook via the Graph API on a test user account for my app. 我正试图通过我的应用程序的测试用户帐户上的Graph API将照片上传到Facebook。 With just the url, link, name parameters present, the upload works fine returning a valid photo id. 只显示url, link, name参数,上传工作正常,返回有效的照片ID。

However, if I use the additional tags parameter, I end up with the following error returned: 但是,如果我使用其他tags参数,我最终会返回以下错误:

{
  "error": {
    "message": "(#100) param tags must be an array.", 
    "type": "OAuthException", 
    "code": 100
  }
}

I've tried to provide the value for tags in almost every possible way I can think of, as I know the Graph API isn't straightforward (even the parameter url which is used to upload a photo from a URL isn't listed under the photo Graph API method); 我试图以几乎所有可能的方式提供tags的值,因为我知道Graph API并不简单(甚至用于从URL上传照片的参数url也没有列在photo图谱API方法);

A single user id 单个用户ID

tags=100003919104407

Multiple CS'd user ids 多个CS'd用户ID

tags=100003919104407,100003919104408,100003919104409

Array with ids not as integers 数组的id不是整数

tags=[100003919104407, 100003919104404,100003919104405]

Array with ids as strings 将id作为字符串的数组

tags=["100003919104407", "100003919104404","100003919104405"]

Array containing objects, as per the Facebook Graph API documentation 包含对象的数组,根据Facebook Graph API文档

tags=[{"id":"100003919104407"},{"id":"100003919104404"},{"id":"100003919104405"}]

If someone could tell me the right format/another parameter through which to pass user ids in order to have them tagged in a photo, I'd be very grateful. 如果有人能告诉我正确的格式/另一个传递用户ID的参数,以便在照片中标记它们,我将非常感激。

Try this 尝试这个

It should be in this format 它应该采用这种格式

[{"to":"100003919104407","x":0,"y":0},  
{"to":"100003919104408","x":10,"y":10},  
{"to":"100003919104409","x":20,"y":20}] 

or 要么

[{"tag_uid":"100003919104407","x":0,"y":0},
{"tag_uid":"100003919104408","x":10,"y":10},
{"tag_uid":"100003919104409","x":20,"y":20}]

Where did you get your information from? 你是从哪里获得你的信息的? Have you check the tags section? 你查看了标签部分吗?

Create 创造

You can create a tag on the photo by issuing an HTTP POST request to the tags connection, PHOTO_ID/tags. 您可以通过向标记连接PHOTO_ID /标记发出HTTP POST请求来在照片上创建标记。

Note: This feature is intended to help users tag their friends in real photos. 注意:此功能旨在帮助用户在真实照片中标记他们的朋友。 You should not use this feature to encourage users to tag their friends if their friends are not actually in that photo, or to tag friends in composite photos. 如果他们的朋友实际上不在该照片中,或者在合成照片中标记朋友,则不应使用此功能来鼓励用户标记他们的朋友。 If your app is found to be encouraging this behavior, your usage of this feature may be disabled. 如果发现您的应用程序鼓励此行为,则可能会禁用此功能。

You can specify which user to tag using two methods: in the URL path as PHOTO_ID/tags/USER_ID, or in a URL parameter as PHOTO_ID/tags?to=USER_ID. 您可以使用两种方法指定要标记的用户:在URL路径中为PHOTO_ID / tags / USER_ID,或在URL参数中为PHOTO_ID / tags?to = USER_ID。 To add several tags at once, you can specify a tags property which contains an array of tags like so PHOTO_ID/tags?tags=[{"id":"1234"}, {"id":"12345"}]. 要一次添加多个标签,您可以指定一个tags属性,其中包含一组标签,如PHOTO_ID / tags?tags = [{“id”:“1234”},{“id”:“12345”}]。 Currently, you cannot tag a Page in a photo using this API. 目前,您无法使用此API标记照片中的页面。

There's also an example . 还有一个例子

the X and Y value of array need to be %, not in pixels 数组的X和Y值需要为%,而不是像素

Example 1 (wrong) 例1(错误)

img:(640,480) xy:(320,240) [{tag_uid:user_id,x:320,y:240}] <- wrong, because 320 > 100% img:(640,480)xy:(320,240)[{tag_uid:user_id,x:320,y:240}] < - 错误,因为320> 100%

Example 2 (right) img:(640,480) xy:(320,240) px:(320,240) < % 例2(右) img:(640,480)xy:(320,240)px:(320,240)<%

[{tag_uid:user_id,x:50,y:50}] <- right, because 50 < 100% [{tag_uid:user_id,x:50,y:50}] < - 右,因为50 <100%

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM