Skip to content

Instantly share code, notes, and snippets.

@ozh
Created September 5, 2010 17:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ozh/566198 to your computer and use it in GitHub Desktop.
Save ozh/566198 to your computer and use it in GitHub Desktop.
<?php
/*
How To Mirror Remote Images On Tumblr With WordPress
*/
// URL of the image you want to mirror. Here: Girl in pink underwear.
$image = 'http://i.imgur.com/Hq4QA.jpg';
// URL of the Tumblr API
$api = 'http://www.tumblr.com/api/write';
// Parameters of the POST request
$options = array(
'email' => 'email@yoursite.com',
'password' => '123456',
'type' => 'photo',
'source' => $image
);
// Do the POST
var_dump( wp_remote_post( $api, array( 'body' => $options, 'timeout' => 20 ) ) );
/* Example output:
array(4) {
["headers"]=>
array(8) {
["date"]=>
string(29) "Sun, 05 Sep 2010 17:32:42 GMT"
["server"]=>
string(21) "Apache/2.2.3 (CentOS)"
["p3p"]=>
string(46) "CP="ALL ADM DEV PSAi COM OUR OTRo STP IND ONL""
["content-length"]=>
string(2) "10"
["vary"]=>
string(15) "Accept-Encoding"
["x-tumblr-usec"]=>
string(10) "D=14995333"
["connection"]=>
string(5) "close"
["content-type"]=>
string(25) "text/plain; charset=utf-8"
}
["body"]=>
string(10) "1070574277"
["response"]=>
array(2) {
["code"]=>
int(201)
["message"]=>
string(7) "Created"
}
["cookies"]=>
array(0) {
}
}
*/
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment