/** * 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(); } } } }
<form method="post" action="<?php echo $_SERVER['PHP_SELF']; ?> "> <input type="hidden" name="action" value="list_feed" /> <input type="hidden" name="api_key" value="ce2827565b9410316713848c32dd354355efb2ba" /> <input type="submit" value="Get Feed List" /> </form> <?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>"; }