Skip to content

Instantly share code, notes, and snippets.

@sbseltzer
Created February 12, 2012 05:56
Show Gist options
  • Save sbseltzer/1806624 to your computer and use it in GitHub Desktop.
Save sbseltzer/1806624 to your computer and use it in GitHub Desktop.
Testing TumblrRWU
<?php
header( "Content-Type: text/plain" );
echo "Welcome to the test!\n";
include "TumblrReader.php";
include "TumblrWriter.php";
include "TumblrUser.php";
$consumer_key = 'your_consumer_key';
$consumer_secret = 'your_secret_key';
$username = 'username@example.com';
$password = '******';
echo "Creating reader...\n";
$reader = new TumblrReader( $consumer_key, $consumer_secret, $username, $password );
echo "Creating writer...\n";
$writer = new TumblrWriter( $consumer_key, $consumer_secret, $username, $password );
echo "Creating user...\n";
$user = new TumblrUser( $consumer_key, $consumer_secret, $username, $password );
$base_hostname = 'www.geekwithalife.com';
echo "Beginning tests on TumblrReader...\n";
echo "Getting Info for $base_hostname\n";
print_r( $reader->getInfo( $base_hostname ) );
echo "Getting Avatar for $base_hostname\n";
print_r( $reader->getAvatar( $base_hostname ) );
echo "Getting Followers for $base_hostname\n";
print_r( $reader->getFollowers( $base_hostname ) );
echo "Getting Posts for $base_hostname\n";
print_r( $reader->getPosts( $base_hostname ) );
echo "Getting Queue for $base_hostname\n";
print_r( $reader->getQueue( $base_hostname ) );
echo "Getting Drafts for $base_hostname\n";
print_r( $reader->getDrafts( $base_hostname ) );
echo "Getting Submissions for $base_hostname\n";
print_r( $reader->getSubmissions( $base_hostname ) );
echo "Beginning tests on TumblrWriter...\n";
echo "Posting to $base_hostname\n";
$writer->post( $base_hostname, array( 'type'=>'text', 'title'=>'Test Post', 'body'=>'Posted from my TumblrWriter class' ) );
$lastPost = $reader->getPosts( $base_hostname, array( 'limit' => 1 ) );
$lastPostID = $lastPost->id;
echo "Editing post $lastPostID on $base_hostname\n";
$writer->edit( $base_hostname, $lastPostID, array( 'type'=>'text', 'title'=>'Test Post (Edited)', 'body'=>'This post has been edited by my TumblrWriter class' ) );
$otherBlog = 'weekoftheday.tumblr.com';
$lastPost = $reader->getPosts( $otherBlog, array( 'limit' => 1 ) );
$lastPostID = $lastPost->id;
echo "Reblogging post $lastPostID from $otherBlog to $base_hostname\n";
$writer->reblog( $base_hostname, $lastPostID, $lastPost->reblog_key, "Reblogged by my TumblrWriter class" );
echo "Posting again to $base_hostname\n";
$writer->post( $base_hostname, array( 'type'=>'text', 'title'=>'Test Delete', 'body'=>'This post will be deleted shortly.' ) );
$lastPost = $reader->getPosts( $base_hostname, array( 'limit' => 1 ) );
$lastPostID = $lastPost->id;
echo "Deleting post $lastPostID from $base_hostname\n";
$writer->delete( $base_hostname, $lastPostID );
echo "Beginning tests on TumblrUser...\n";
echo "Getting Info for $username\n";
print_r( $user->getInfo() );
echo "Getting Dashboard for $username\n";
print_r( $user->getDashboard() );
echo "Getting Likes for $username\n";
print_r( $user->getLikes() );
echo "Getting Followed Blogs for $username\n";
print_r( $user->getFollowing() );
$otherBlog = 'blog.gmodgcc.org';
echo "Attempting to make $username follow $otherBlog\n";
print_r( $user->follow( $otherBlog ) );
echo "Attempting to make $username unfollow $otherBlog\n";
print_r( $user->unfollow( $otherBlog ) );
$lastPost = $reader->getPosts( $otherBlog, array( 'limit' => 1 ) );
$lastPostID = $lastPost->id;
echo "Attempting to make $username like post $lastPostID on $otherBlog\n";
print_r( $user->like( $otherBlog, $lastPostID, $lastPost->reblog_key ) );
echo "Attempting to make $username unlike post $lastPostID on $otherBlog\n";
print_r( $user->unlike( $otherBlog, $lastPostID, $lastPost->reblog_key ) );
echo "Testing complete!\n";
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment