http://www.tumblr.com/docs/en/api#api_write

I'm actually using their example piece of code, edited to reference my username/password combination but I'm being told I've not got a correct connection string.

Has anyone successfully used Tumblr in this way in PHP? I'd really like some advice and help.

Thanks

    Hi.
    What example of code do you use?

    Someimes they require email/password, sometimes username/password.

    This standard PHP example uses
    - tumblr_email
    - tumblr_password
    - CURL request

    <?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";
    }
    
    ?>

      That's the example code I used but I changed the email and password to be my tumblr email and password.

      I get Authentication failed every time.

      I've tried to call http://tumblr.com/api/authentication too and got the same thing.

      I'm hoping someone has some code that works for them they can show me (without giving me their login details obv!) that I can try running too. Maybe it's something to do with my PHP.INI?

      Cheers

        10 days later

        Hey, this is resolved. It turns out you can't get authentication if you're running this call from XAMPP. From the live server it's fine.

        No idea why...

          6 months later

          hello,
          i have the same problem with "Bad email or password".
          i use xampp and the code from the second post but the solution with the live server won&#180;t work for me.
          the email and password are the right ones. i&#180;ve tried to change the pass and email in tumblr but this also failed.

          it would be very nice if somebody has a different solution.

            Write a Reply...