getRequestHandler(); $requestHandler->setBaseUrl('https://www.tumblr.com/'); list($token, $token_secret) = tumblr_tokens($client, $requestHandler); // Authenticate via OAuth $client = new Tumblr\API\Client( $consumer_key, $consumer_secret, $token, $token_secret ); // Echo HTML contents echo ' Vox Populi - A Tumblr Web Client
'; // Get the user's blog name for welcome message $client->getUserInfo(); foreach ($client->getUserInfo()->user->blogs as $blog) { echo '

Search results for: ' . $_GET['query'] . '

'; } // Create function to allow a client to get 20 posts per page function get_tagged_posts($client, $before_date, $limit) { $tag = $_GET['query']; $tagged_posts = $client->getTaggedPosts($tag, $options=null); $card_columns = '
'; foreach ($tagged_posts as $post) { $card_columns .= '
'; $card_columns .= '
'; $card_columns .= '' . $post->blog_name . '
'; if ($post->followed != true) { // Send user to action.php to follow a new blog $query_string = 'action=follow&blog_name=' . urlencode($post->blog_name) . '&callback=' . urlencode('https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']); $card_columns .= '
'; } else { $card_columns .= '
'; } $card_columns .= post_media($post); $card_columns .= '
'; $card_columns .= post_content($post); /* This seems to just post a duplicate of a QA answer if (isset($post->reblog->comment) && $post->reblog->comment !== '') { $card_columns .= '

' . $post->reblog->comment . '

'; } */ // $card_columns .= 'Visit Post →'; $card_columns .= ''; $card_columns .= '
'; } $card_columns .= '
'; return $card_columns; } // Create a loop to call as many dashboard posts as you want (results are returned in sets of 20 per API rules) // Can specify post type: text, chat, link, photo, audio, video, NULL if (isset($_GET['type'])) { $post_type = $_GET['type']; } else { $post_type = NULL; } if (isset($_GET['page'])) { $page = $_GET['page']; } else { $page = 1; } $post_start = (($page - 1) * 20) + 1; $limit = 20; echo get_tagged_posts($client, $post_start, $limit, $post_type); echo '
'; ?>