posts->post); if($count == 0) break; foreach($xml->posts->post as $post) { $postId = (string)$post[id]; echo $postId . "\n"; $request_data = http_build_query( array( 'email' => $tumblr_email, 'password' => $tumblr_password, '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, $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\n"; else echo "Error: $result\n"; } } while($count > 0); ?>