I have what I thought was a simple requirement. Through a Facebook App, enable a user to upload a predefined image (from within the app) to their own album.
Uploading an image from the user's machine is straight forward and is described here, https://developers.facebook.com/blog/post/498/.
What I need to do is substitute the file input for a predefined image. My first though was to control the POST through the server (PHP), converting the image to a bit array.
$byteArray = file_get_contents("../images/gate-banner.jpg");
$data = array(
"message" => "test",
"source" => $byteArray
);
$postdata = http_build_query($data);
$opts = array('http' =>
array(
'method' => 'POST',
'header' => 'Content-type: multipart/form-data',
'content' => $postdata
)
);
$context = stream_context_create($opts);
print_r(file_get_contents($graph_url, false, $context));
But this keeps kick back a 400 Bad Request.
What am I missing? Is there a simpler way to accomplish my goal?
Rich