i'm trying make photo upload, but i'm not getting, well the goal was publish in my fan page wall, i cann't, so i decided to test in my wall "me/photo", same thing, this error appears!
CurlException failed creating formpost data
this is my code, and the page "config.php" contains only configurations, appid, secret, etc...
anyway, What am i do wrong?
$photo = '/imagens/teste.jpg'; // Path to the photo on the local filesystem
$message = 'Photo upload via the PHP SDK!';
?>
<html>
<head></head>
<body>
<?php
if($idUsuario) {
// We have a user ID, so probably a logged in user.
// If not, we'll get an exception, which we handle below.
try {
// Upload to a user's profile. The photo will be in the
// first album in the profile. You can also upload to
// a specific album by using /ALBUM_ID as the path
$ret_obj = $facebook->api('/me/photos', 'POST', array(
'access_token'=> $facebook->getAccessToken(),
'source' => '@'.$photo,
'message' => $message
)
);
echo '<pre>Photo ID: ' . $ret_obj['id'] . '</pre>';
echo '<br /><a href="' . $facebook->getLogoutUrl() . '">logout</a>';
} catch(FacebookApiException $e) {
// If the user is logged out, you can have a
// user ID even though the access token is invalid.
// In this case, we'll get an exception, so we'll
// just ask the user to login again here.
$login_url = $facebook->getLoginUrl( array(
'scope' => 'photo_upload'
));
echo 'Please <a href="' . $login_url . '">login.</a>';
error_log($e->getType());
error_log($e->getMessage());
}
} else {
// No user, print a link for the user to login
// To upload a photo to a user's wall, we need photo_upload permission
// We'll use the current URL as the redirect_uri, so we don't
// need to specify it here.
$login_url = $facebook->getLoginUrl( array( 'scope' => 'photo_upload') );
echo 'Please <a href="' . $login_url . '">login.</a>';
}
?>
</body>
</html>
You can see that this code is the same code example in dvelopers.facebook to make upload!
You must send the realpath to the API.
Change:
$photo = '/imagens/teste.jpg';
By:
$photo = realpath('/imagens/teste.jpg');
And check if your path is good.