Our app uses the PHP开发者_开发知识库- aswell as the JS-SDK of Facebook. We are able to access the users-images and the images of his friends thru both sdks. The upload of photos into user-albums works aswell.
The user currently selects one of his images which gets manipulated on our server and uploaded to Facebook into the album it came from. That part works. We now want to post that uploaded image onto the users wall. Facebook itself generates a post on the users feed about newly uploaded images (can be disabled on the uploading request) but those posts are not customizable. The standard facebook-post request requires an url to the optional photo. The documentaton states that it is not allowed to link to images from the facebook content delivery-network (which has been confirmed by the graph api as it throws an appropriate error).
Is it possible to create a standard wall-post that contains a gallery-image somehow? Ideally it would use the gallery-popup but that is clearly super-nice-to-have.
An externally hosted copy is an (unwanted) workaround that we already know. Reuploading the image is an option as long as it does not show up in the gallery twice.
Simple solution :
Get a tinyurl for you fbcdn'ed picture through tinyurl api:
Example with url from above :
http://tinyurl.com/api-create.php?url=http://a4.sphotos.ak.fbcdn.net/hphotos-ak-snc3/13943_196960329960_683709960_2997879_7206516_n.jpg
Returns :
http://tinyurl.com/3ta96kh
Then use this url as the "picture", I tried it here and it works ! : http://jsfiddle.net/dwarfy/VYAeD/27/
There was another solution here but It seems facebook corrected it and it still says the error with facebook CDN when I post using https://graph.facebook.com/PICTURE_ID as picture instead of the FBCDN image url.
I think it's the best solution ...
My example doesn't use the link parameter but you could set it to the gallery image ...
Indeed you can't post to users' walls image saved on fb BUT also you don't have to save it physically on you server. if you want to post an image, for example:
http://a4.sphotos.ak.fbcdn.net/hphotos-ak-snc3/13943_196960329960_683709960_2997879_7206516_n.jpg
facebook as you know will not accept this. but ther is no problem to post something like this: http://yourserver.com/script.php?image=a4.sphotos.ak.fbcdn.net/hphotos-ak-snc3/13943_196960329960_683709960_2997879_7206516_n.jpg (without http:// -- its important, if you include http:// facebook will find out what's going - and we don't want it:)
script.php is a php file on your server that do this:
<?
$url = "http://".$_GET['image'];
header('Content-type: image/jpeg');
echo file_get_contents($url);
?>
or something like this:
<?
$url = "http://".$_GET['image'];
$image = imagecreatefromjpeg($url);
//some image modifications here//
header('Content-type: image/jpeg');
echo imagejpeg($image, null, 100);
?>
you can also add an database with urls and post something like this: http://yourserver.com/script.php?imageid=ID hiding all images' real paths.
If you want to save on traffic after publishing images on walls just redirect:
<?
//if published then just redirect
$url = "http://".$_GET['image'];
header('Location: '.$url); die();
?>
You have to make the copy of that image otherwise there is no way you can use this image in standard post dialog.
Use PHP function
copy()
I know you are looking for any other alternative but to create a spare image on your server or any other server is the only solution.
精彩评论