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?
This works fine for me on pages:
Might want to try switching from 'image' to 'url'
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.