We can post text as well as photo from my own site like mysite to Tumblr. For that I have got code by searching google. For blog post in Tumblr We need tumblr user name and password.After then We can post text as well photo using curl.

The full code is given below:

<?php

// Authorization info
$tumblr_email    = 'info@davidville.com';
$tumblr_password = 'secret';

// Data for new record
$post_type  = 'regular';
$post_title = 'The post title';
$post_body  = 'This is the body of the post.';

// Prepare POST request
$request_data = http_build_query(
    array(
        'email'     => $tumblr_email,
        'password'  => $tumblr_password,
        'type'      => $post_type,
        'title'     => $post_title,
        'body'      => $post_body,
        'generator' => 'API example'
    )
);

// Send the POST request (with cURL)
$c = curl_init('http://www.tumblr.com/api/write');
curl_setopt($c, CURLOPT_POST, true);
curl_setopt($c, CURLOPT_POSTFIELDS, $request_data);
curl_setopt($c, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($c);
$status = curl_getinfo($c, CURLINFO_HTTP_CODE);
curl_close($c);

// Check for success
if ($status == 201) {
    echo "Success! The new post ID is $result.\n";
} else if ($status == 403) {
    echo 'Bad email or password';
} else {
    echo "Error: $result\n";
}

?>

Or we should see http://www.tumblr.com/docs/en/api#reblogging_posts how to post text as well as photo

 

2 thoughts on “Tumblr Blogpost from my site like”

  1. Hi,

    I am babu , i tried to post in blog via curl using php ,

    I got response as “Success! The new post ID is ” , but i dint get any updates in my blog , my blog : “babut.tumblr.com”

    $tumblr_email = ‘info@davidville.com’;
    $tumblr_password = ‘secret’; – // hav to give my password or secret , pls help me about this

    Thanks in advance

    babu

  2. We’re a group of volunteers and opening a new scheme in our community.
    Your website provided us with valuable info to work on.
    You have done a formidable job and our whole community will
    be thankful to you.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.