发布到组时出现OAuthException

发布到组时出现OAuthException

本文介绍了尝试将照片上传/发布到组时出现OAuthException的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我目前正在尝试通过应用将照片上传到页面和群组.我有以下代码:

I am currently trying to upload photos to pages and groups through an app. I have these codes:

try
{
    $facebook->setFileUploadSupport(true);
    $args = array('message' => 'This is my image caption',);
    $args['image'] = '@'.realpath('./uploads/terragarden1.png');
    $response = $facebook->api('/GROUP_ID/photos/','POST',$args);
}
catch(FacebookApiException $e)
{
     echo "Error: ".$e;
}

$args['image']的值将如下所示:

@/home/publica/public_html/AutoPost/uploads/terragarden1.png

问题是它抛出一个OAuthException: An unknown error has occurred.我不太了解如何处理这种错误.

The problem is that it throws an OAuthException: An unknown error has occurred. I don't quite know what to do with this kind of error.

附加:
当我尝试使用相同的代码发布图片并只是更改
$response = $facebook->api('/GROUP_ID/photos/','POST',$args);

Additional:
When I try to post image using the same code and just changing
$response = $facebook->api('/GROUP_ID/photos/','POST',$args);

进入$response = $facebook->api('/me/photos/','POST',$args);,图像将成功发布到用户的墙上.这里可能是什么问题?

into $response = $facebook->api('/me/photos/','POST',$args);, the image would successfully be posted on the user's wall. What might be the problem here?

推荐答案

在页面上对我来说效果很好:

This works fine for me on pages:

$attachements = array(
        'access_token' => $page->getToken(),
        'message' => $post_pub['title'],
        'url' => 'http://site.com/images/your_image.png' );
        try{
           $result = $facebook->api('/'.$page->getIdFacebook().'/photos', 'POST', $attachements, function(){
           });
        }
        catch(Exception $e){ }

可能想尝试从图片"切换到网址"

Might want to try switching from 'image' to 'url'

这篇关于尝试将照片上传/发布到组时出现OAuthException的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-27 18:20