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?