Jump to content

Push image a multipart form data?


papaface

Recommended Posts

Hello,

 

I am currently working with the Twitter API. Those of you who are familar with it will know that to update the background image on a given Twitter account, you need the submit the given image to the API in multipart form.

 

This is really confusing me and any help would be appreciated.

 

My code at the moment is:

error_reporting(E_ALL);
ini_set('display_errors', '1');
ini_set('memory_limit', '1600M');
require("twitter.php");

$twitter = new Twitter("///","////");


// Set the content-type
//header('Content-type: image/jpeg');

// Create the image
$im = imagecreatefromjpeg("background.jpg");
$white = imagecolorallocate($im, 255, 255, 255);
$grey = imagecolorallocate($im, 62, 51, 54);
$black = imagecolorallocate($im, 95, 95, 95);

// The text to draw
// Replace path by your own font path
$font = 'MyriadPro-SemiboldSemiExt.otf';

// Add some shadow to the text


// Add the text
//imagettftext($im, 20, 90, 34, 500, $black, $font, $text);
$text = 'Some random text';
/*imagettftext($im, 20, 90, 78, 538, $grey, $font, $text);
imagettftext($im, 20, 90, 74, 538, $black, $font, $text);*/
imagettftext($im, 20, 90, 77, 536, $white, $font, $text);
imagettftext($im, 20, 90, 74, 538, $black, $font, $text);
imagejpeg($im, 'simpletext.jpg');
//echo '<img src="simpletext.jpg" />';
// Using imagepng() results in clearer text compared with imagejpeg()
$mime_boundary=md5(time());
$headers .= 'From: My Email <me@company.com>' . "\n";
$headers .= 'MIME-Version: 1.0'. "\n";
$headers .= "Content-Type: multipart/mixed; boundary=\"".$mime_boundary."\"". "\n";

if	($twitter->updateProfileBackgroundImage("simpletext.jpg"))
{
echo "done";
}
else
{
echo "problem";
}
//imagejpeg($im);

?>

But this is giving me this error:

Fatal error: Uncaught exception 'TwitterException' with message 'Not Implemented' in /twitter.php:1230 Stack trace: #0 /process.php(42): Twitter->updateProfileBackgroundImage('simpletext.jpg') #1 {main} thrown in /twitter.php on line 1230

 

Any help would be appreciated :'(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.