function fs_fetch_feedburner_data($url, $action, $get = '', $fetcher = false) { // Let's instantiate our result variable ahead of time, assuming // that the result will not be a success $result = array('success' => false); $name = ''; if ($url == '') { // If no URL was passed in, stop now and return an error message $result['error'] = fs_translatable_error('Configuration needed'); return $result; } elseif (preg_match("|(http:\\/\\/)?feed(.*)\\.com\\/|", $url) != 0) { // If we're using a Google FeedBurner/Google FeedProxy feed, // we'll use PCRE to grab the feed name (temporarily stored in // the $name variable) $name = preg_replace("|(http:\\/\\/)?feed(.*)\\.com\\/|", "", $url); } else { // For backwards compatibility reasons, if the feed URL isn't // a URL, we'll assume that it's the feed name $name = $url; } // Generate our request string $format = "https://feedburner.google.com/api/awareness/1.0/%s?uri=%s&%s"; $request = sprintf($format, $action, $name, $get); // Try to pull down the data $response = fetch_remote_xml($request, $fetcher); // Search through the feed for errors if (preg_match('|rsp stat="fail"|', $response->body)) { // If there's an error embedded in the feed response, make it // grammatically correct and translatable preg_match('|msg="(.*?)"|', $response->body, $msg); $result['error'] = fs_translatable_error($msg[1]); } elseif ($response->status == "401") { // If the feed does not permit AwAPI access, return that; // sometimes $result['error'] = fs_translatable_error('This feed does not permit Awareness API access'); } elseif ($response->status == "500") { // If FeedBurner is giving us an internal server error, // return the boilerplate message $result['error'] = fs_translatable_error('Feedburner issues'); } elseif (strlen($response->body) == 0) { // If there was no data returned, then there was some // problem with trying to contact FeedBurner $result['error'] = fs_translatable_error('Cannot access FeedBurner'); } elseif ($response->status == "200") { // Everything went well, so return the response from // FeedBurner back to the user $result['success'] = true; $result['status'] = $response->status; $result['data'] = $response->body; $result['url'] = $data->url; } else { // We have no idea what went wrong; tell that to the user $result['error'] = fs_translatable_error('Unknown error'); } // Send the engine as well (for debugging purposes) $result['engine'] = $response; // Return our result array to the user return $result; }
printf(__('<a href="%s">Feed Stats Settings</a> » Troubleshooting', 'feed-stats-plugin'), "options-general.php?page=feed-stats-options"); ?> </h2> <p> <?php printf(__("I've compiled this page of information to help you \nget past those pesky error messages. If you have any questions that \naren't answered on this page, feel free to send a message to this \nplugin's <a href='%s'>mailing list</a>.", 'feed-stats-plugin'), SUPPORT_URL); ?> </p> <?php // Compile the list of error messages that we're going to display $types = array('This feed does not permit Awareness API access', 'Feed Not Found', 'Cannot access FeedBurner', 'Feedburner issues', 'Unknown'); // Loop though all of the errors and display the title and messages foreach ($types as $type) { // Get the error $error = fs_translatable_error($type); ?> <h3><?php echo $error['title']; ?> </h3> <p><?php echo $error['message']; ?> </p> <?php }
/* Copyright (c) 2008 - 2009 Jonathan Wilde This file is part of Feed Stats for WordPress. Feed Stats for WordPress is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 2 of the License, or (at your option) any later version. Feed Stats for WordPress is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with Feed Stats for WordPress. If not, see <http://www.gnu.org/licenses/>. */ // Figure out the URL for the information at FeedBurner $feed = urldecode($_GET['feed']); $response = fs_fetch_feedburner_data($feed, "GetFeedData", false); $template = "[result][%+d] %s[result]"; // If there are no errors, tell the user that the feed is valid; if // there are errors, print them out directly. if ($response['success'] == true) { $status = fs_translatable_error("Valid"); printf($template, $status['code'], $status['title']); } else { printf($template, $response['error']['code'], $response['error']['title']); }