Permalink
Browse files

Catching error when testing for key

  • Loading branch information...
1 parent 12a526e commit 5f29c4c82cccfbea0e55599061479a350c3f36c3 Sabrina Leandro committed Mar 21, 2013
Showing with 15 additions and 5 deletions.
  1. +5 −2 readme.txt
  2. +1 −1 songkick_concerts_and_festivals.php
  3. +9 −2 songkick_events.php
View
@@ -2,8 +2,8 @@
Contributors: saleandro, coox
Tags: songkick, concerts, events, festivals, widget
Requires at least: 2.8.2, PHP 5 or higher
-Tested up to: 3.4.2
-Stable tag: 0.9.4.3
+Tested up to: 3.5.1
+Stable tag: 0.9.4.4
This plugin lets you display events for a Songkick user, artist, venue, or metro area on your WordPress blog, as a widget or shortcode.
@@ -141,3 +141,6 @@ See Songkick’s admin settings for details.
= 0.9.4.3 =
* Bug fix: Fixing error when displaying a user's upcoming events
+
+= 0.9.4.4 =
+* Catching any error when testing Songkick API key. Some users reported seeing a "name lookup" error on the Settings page.
@@ -6,7 +6,7 @@
Description: Plugin to show concerts based on your Songkick profile. It can display upcoming events for a user, an artist, venue, or metro area/location.
It can also display past events for users and artists. For a user, simply put your username in the admin interface. For an artist, you should use the artist's Songkick id, as shown in the url for your artist page.
For example, the url "http://www.songkick.com/artists/123-your-name" has the id "123". The same goes for metro areas or venues: "http://www.songkick.com/venues/123-venue-name" and "http://www.songkick.com/metro_areas/123-city-name" both have the id "123".
-Version: 0.9.4.3
+Version: 0.9.4.4
Author: Sabrina Leandro
Author URI: http://github.com/saleandro
License: GPL3
View
@@ -1,6 +1,7 @@
<?php
class InvalidApiKeyException extends Exception { }
+class HttpError extends Exception { }
class SongkickEvents {
public $apikey;
@@ -23,7 +24,13 @@ function get_events($page=1, $per_page=10) {
}
function test_api_call() {
- $this->fetch("$this->apiurl/metro_areas/24426/calendar.xml?apikey=$this->apikey&page=1&per_page=1");
+ try {
+ $this->fetch("$this->apiurl/metro_areas/24426/calendar.xml?apikey=$this->apikey&page=1&per_page=1");
+ } catch (HttpError $e) {
+ $msg = 'Error on ' . get_bloginfo('url') . ' while trying to test Songkick Concerts plugins API key: ' . $e->getMessage();
+ error_log($msg, 0);
+ return '';
+ }
}
protected function get_cached_results($key) {
@@ -59,7 +66,7 @@ protected function fetch($url) {
$response = $http->request($url);
if (is_wp_error($response)) {
- throw new Exception('WP_Http/WP_Error message: '.$response->get_error_message());
+ throw new HttpError('WP_Http/WP_Error message: '.$response->get_error_message());
} elseif (!is_array($response)) {
throw new Exception('WP_Http/Invalid response');
} elseif ($response['response']['code'] == 403) {

0 comments on commit 5f29c4c

Please sign in to comment.