The program will load the user profile image and then apply the effect to it through imagemagick. Since the facebook example is intended only for the file base, and I do not want to store it as a temporary file, how to upload a finalized binary image to facebook
<?php
$overlay = new Imagick('1.png');
$base = new Imagick();
$base->readImageFile(fopen('https://graph.facebook.com/'.$id.'/picture?type=large', 'rb'));
$base->compositeImage($overlay, Imagick::COMPOSITE_DEFAULT, 0, 0);
$options = array(
CURLOPT_URL => "https://graph.facebook.com/me/staging_resources",
CURLOPT_POST => true,
CURLOPT_HTTPHEADER => Array("Content-Type: multipart/form-data"),
CURLOPT_POSTFIELDS => array(
'file' => 'data:image/png;base64,'.base64_encode($base),
'access_token' => ''
)
);
$ch = curl_init();
curl_setopt_array($ch, $options);
echo curl_exec($ch);
?>
source
share