-
-
Save georgemiler/6153011 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
// ------WARNING------ | |
// RUNNING THIS FILE WITH THE APPROPRIATE CREDENTIALS WILL | |
// ERASE ALL YOUR POSTS FROM YOUR TUMBLR BLOG! | |
// Tumblr Blog Info | |
//replace YOUR-TUMBLR-EMAIL with the email you are using to login to Tumblr | |
$tumblrEmail = 'YOUR-TUMBLR-EMAIL'; | |
//replace YOUR-TUMBLR-PASSWORD with the password you enter when logging in Tumblr | |
$tumblrPassword = 'YOUR-TUMBLR-PASSWORD'; | |
//replace YOUR-TUMBLR-DOMAIN with the subdomain of the tumblr url you are using | |
// e.g. if your Tumblr blog is at http://lala.tumblr.com, then | |
// replace YOUR-TUMBLR-DOMAIN with lala | |
$tumblrDomain = 'YOUR-TUMBLR-DOMAIN'; | |
$i = 0; | |
do { | |
$xml = simplexml_load_file("http://" . $tumblrDomain . ".tumblr.com/api/read?start=" . $i . "&num=50&rand=" . rand()); | |
$i += 50; | |
$count = count($xml->posts->post); | |
if($count == 0) | |
break; | |
foreach($xml->posts->post as $post) { | |
$postId = (string)$post[id]; | |
echo $postId . "\n"; | |
$requestData = http_build_query( | |
array( | |
'email' => $tumblrEmail, | |
'password' => $tumblrPassword, | |
'post-id' => $postId, | |
'generator' => 'API example' | |
) | |
); | |
// Send the POST request (with cURL) | |
$c = curl_init('http://www.tumblr.com/api/delete'); | |
curl_setopt($c, CURLOPT_POST, true); | |
curl_setopt($c, CURLOPT_POSTFIELDS, $requestData); | |
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 == 403) | |
echo "Bad email or password\n"; | |
else | |
echo $result . "\n"; | |
} | |
} while($count > 0); | |
?> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment