将用户的照片上传到Facebook页面 [英] Tag users in a photo uploaded to a facebook page

查看:133
本文介绍了将用户的照片上传到Facebook页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试将照片上传到特定页面,该页面正在运行,但现在我想标记我刚刚上传到页面的照片中的当前身份验证用户。



这是我的代码,

  $ result = $ facebook-> api('/ PAGE_ID / photos ','post',array(
'source'=>'@ pic.jpeg',
'message'=>'忍者本月!!!',
' access_token'=>'PAGE_TOKEN',
'tags'=>数组(数组(
'tag_uid'=> CURRENT_USERS_UID,
'x'=> 0,
'y'=> 0
))
));

当我尝试我得到这个错误致命错误:未捕获OAuthException:( #322)抛出无效的照片标签主题,我已经确保该页面允许用户被标记,并且我拥有所需的权限, status_update,publish_stream,user_photos,offline_access ,manage_pages



任何想法为什么会发生这种情况,以及我如何解决它?

解决方案>

我想您可能需要使用不同的 access_token (用户的access_token)来更新标签。



这样的事情可能会起作用。

  $ facebook-> setFileUploadSupport(true); 
$ args = array(
'access_token'=>'PAGE_TOKEN',
'message'=>'MESSAGE',
'image'=>'@ 。realpath($ path_to_user),
);

$ data = $ facebook-> api('/ ALBUM_ID / photos','post',$ args);

$ token = $ facebook-> getAccessToken();

$ argstag = array('to'=>'USER_TO_TAG');
$ argstag ['x'] = 40;
$ argstag ['y'] = 40;
$ argstag ['access_token'] = $ token;
$ datatag = $ facebook-> api('/'。$ data ['id']。'/ tags','post',$ argstag);


I am trying to upload a photo to a specific page, which is working, but now I would like to tag the current authenticated user in that photo I have just uploaded to the page.

Here is my code,

$result = $facebook->api('/PAGE_ID/photos', 'post', array(
        'source'        => '@pic.jpeg',
        'message'       => 'Ninja of the month!!!',
        'access_token'  => 'PAGE_TOKEN',
        'tags'          => array(array(
                              'tag_uid'=> CURRENT_USERS_UID,
                              'x'      => 0,
                              'y'      => 0
        ))
));

when I try that I get this error Fatal error: Uncaught OAuthException: (#322) Invalid photo tag subject thrown, I have made sure that the page allows users to be tagged, and that I have the required permissions, status_update,publish_stream,user_photos,offline_access,manage_pages.

Any idea why this could be happening and how I can fix it?

解决方案

I think you might need to update the tags with the different access_token (user's access_token).

something like this might work

$facebook->setFileUploadSupport(true); 
$args = array(
'access_token'  => 'PAGE_TOKEN',
'message' => 'MESSAGE',
'image'   => '@' . realpath($path_to_user),
);

$data = $facebook->api('/ALBUM_ID/photos', 'post', $args);

$token = $facebook->getAccessToken();

$argstag = array('to' => 'USER_TO_TAG');
$argstag['x'] = 40;
$argstag['y'] = 40;
$argstag['access_token'] = $token;
$datatag = $facebook->api('/' . $data['id'] . '/tags', 'post', $argstag);

这篇关于将用户的照片上传到Facebook页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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