Facebook Graph API 2017 - 图片上传到Timeline照片,而不是给予Album(id) [英] Facebook Graph API 2017 - Image uploaded to Timeline Photos instead of given Album (id)

查看:145
本文介绍了Facebook Graph API 2017 - 图片上传到Timeline照片,而不是给予Album(id)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的用户可以决定是否要上传到他们网页的主时间表或页面相册之一。



一切顺利,除了我的图片上传到时间轴照片(默认FB相册),而不是所选的。



如果选择时间轴,$ timelinealbum是我,它是%所以发布网址是/ me / photos,用于时间轴,/%album_id%/ photos为专辑。被调查,运作良好照片仍然转到Timeline照片...



(上传成功时没有错误信息。)



任何想法?



提前感谢!



以下是多张图片的上传代码(静音模式):

  foreach($ tarrvegl as $ t){
$ turl = wp_get_attachment_url($ t);
$ linkDataInner = [
'message'=> $ message,
'source'=> $ fb-> fileToUpload($ turl),
'published'=> false,
'access_token'=> $ page_access_token
];
尝试{
$ response = $ fb-> post('/'.$ timelinealbum。'/ photos',$ linkDataInner);
$ graphNode = $ response-> getGraphNode();
$ resparr [] = $ graphNode ['id'];
} catch(Facebook\Exceptions\FacebookResponseException $ e){
echo'Graph返回错误:'。 $ E->的getMessage();
退出;
} catch(Facebook\Exceptions\FacebookSDKException $ e){
echo'Facebook SDK返回错误:'。 $ E->的getMessage();
退出;
}
}


解决方案

更多更新:child_attachments方法没有将图像上传到FB。新新新新新200新新新新旗新新新旗新新旗新新旗新新旗新新旗新新200新新新旗新新200新新200新新200新新200新新200新新200新新200新新200新新200新名:同时,相册为空:



http:// imgur .com / a / XPjzp



我刚刚放弃了。如果上传了多张图像,我会抓住第一个FB ID,将其发布到该页面(FB创建一个到该相册的链接),然后在帖子底部添加一个关于上传图像数量的注释。 / p>




在联系FB开发人员并获得了一些提示后,我发现一月份有一些变化。 p>

已发布字段已经消失,现在有一个no_story字段,如果已发布为false,则必须为true。 p>

(no_story)的名字很有趣,从1月份的故事中,如果我记得正确的话,从v2.8起就没有了,再也找不到了。有趣的是:在/ page / feed文档中还有已发布,而album_id / photos正在使用no_story字段#wehatelogic)



但是200的X- 200 200 200 200 200 200 -40 200 200 -40 200 200 -40 200 200 -40 200 200 200 200:20045 200 X-最少2个,最多5个(或10个;见文档)图像可以附加到一个帖子,最多5个正在Facebook上显示。



为此,你必须使用一个child_attachments数组。 (不幸的是,如果您只想上传1张图片,则必须使用完全不同的方法#wehateyou)



Facebook for Developers


My users can decide if they want to upload to the main timeline of their page or into one of the page albums.

Everything works successfully, except the fact my images being uploaded to the Timeline Photos (default FB album) instead of the selected one.

$timelinealbum is "me" if the timeline is selected, and it's the "%album_id%", if one of the albums selected.

So the post url is "/me/photos" for timeline, and "/%album_id%/photos" for album. Debugged, working well. Photos still go to Timeline Photos...

(No error message as the upload is successful.)

Any idea?

Thanks in advance!

Here's the upload code for multiple images (silent mode):

foreach ($tarrvegl as $t) {
    $turl = wp_get_attachment_url($t);
    $linkDataInner = [
        'message' => $message,
        'source' => $fb->fileToUpload($turl),
        'published' => false,
        'access_token' => $page_access_token
    ];
    try {
        $response = $fb->post('/'.$timelinealbum.'/photos', $linkDataInner);
        $graphNode = $response->getGraphNode();
        $resparr[] = $graphNode['id'];
    } catch(Facebook\Exceptions\FacebookResponseException $e) {
        echo 'Graph returned an error: ' . $e->getMessage();
        exit;
    } catch(Facebook\Exceptions\FacebookSDKException $e) {
        echo 'Facebook SDK returned an error: ' . $e->getMessage();
        exit;
    }
}

解决方案

More update: the child_attachments method didn't upload the images to FB. A post generated with sidescrolled images, but the images are just linked from my page. Meanwhile the albums are empty:

http://imgur.com/a/XPjzp

I just gave up. If multiple images uploaded, I grab the first's FB ID, make a public post to the page with it (FB creates a link to the album), and just add a note to the bottom of the post about the amount of uploaded images.


After contacting FB developers and got some tips from them, I've found out there were some changes from january.

The "published" field is gone, and there is a "no_story" field now, which have to be "true", if "published" was "false".

(The "no_story" name is funny a little, as from january stories were gone as well from v2.8 if I remember correctly. Can't find that alert again. More funny thing: at "/page/feed" docs there's still "published", while "album_id/photos" is using the "no_story" field. #wehatelogic)

But - and this is more interesting - now it's possible to post multiple images within one query! Minimum of 2, maximum of 5 (or 10; see docs) images can be attached to one post, and maximum of 5 are being displayed on Facebook.

For this, you have to use a "child_attachments" array. (Unfortunately if you want to upload only 1 image, you have to use a completely different method. #wehateyou)

More info at Facebook for Developers

这篇关于Facebook Graph API 2017 - 图片上传到Timeline照片,而不是给予Album(id)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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