OAuthException when trying to upload/post photos to group

三世轮回 提交于 2020-01-03 22:58:46

问题


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; 
}

The value of $args['image'] would be something like this:

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

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.

Additional:
When I try to post image using the same code and just changing
$response = $facebook->api('/GROUP_ID/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?


回答1:


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'




回答2:


I got the same issue.

There is a topic about it here: https://developers.facebook.com/bugs/1430985030446221?browse=external_tasks_search_results_527428908614f7c36099745

I've been tried to do this with js sdk, with the same error response.



来源:https://stackoverflow.com/questions/19720592/oauthexception-when-trying-to-upload-post-photos-to-group

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!