/** * Update blog avatar on feevy * Parameters: * - $user_id: user to fech metadata from */ function feevy_update_avatar() { if (!API_KEY) { return null; } global $user_ID; $avatar_url = author_image_path($user_ID, false); // Check if user has an avatar if (strlen($avatar_url) > 0) { // Get list of user blogs $blogs = get_blogs_of_user($user_ID); // Set avatar for each blog foreach ($blogs as $blog) { $user_count = count(get_users_of_blog($blog->userblog_id)); // Verify blog url if ($user_count == 1 and strlen($blog->siteurl) > 0) { // Set request to Feevy API $api = new feevySoup(); $api->api_key = API_KEY; $api->type = 'edit_avatar'; $api->params = array('feed_url' => "{$blog->siteurl}/feed/", 'avatar_url' => $avatar_url); // Execute request $api->get_content(); } } } }
<?php if (!empty($_POST['action'])) { include "feevySoup.php"; $api = new feevySoup(); // create a new object $api->api_key = $_POST['api_key']; // your API key $api->type = $_POST['action']; // what API method to call? switch ($_POST['action']) { case 'add_feed': $api->params = array('url' => $_POST['url']); break; } $content = $api->get_content(); // get the content if (isset($content['error'])) { echo "<p style=\"color:red;\">{$content['error']}</p>"; } // Go through the array and print the contents foreach ($content['result']['feed'] as $feed) { echo "<img src=\"{$feed['avatar']}\" width=40 height=40 align=middle/><strong>Feed #{$feed['id']}</strong><br />\n"; echo "<ul>\n"; echo "<li>name: {$feed['name']}</li>\n"; echo "<li>url: <a href=\"{$feed['url']}\">{$feed['url']}</a></li>\n"; echo "<li>tags: {$feed['tags']}</li>\n"; echo "</ul>\n"; } } ?>