Changeset 758637
- Timestamp:
- 08/19/2013 05:58:35 PM (13 years ago)
- Location:
- bitly/trunk
- Files:
-
- 3 edited
-
bitly.php (modified) (3 diffs)
-
lib/BitlyService.php (modified) (3 diffs)
-
readme.txt (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
bitly/trunk/bitly.php
r751675 r758637 3 3 Plugin Name: Bitly Official WordPress Plug-in 4 4 Description: A plugin that replaces shared links with Bitly short urls and gives you the option of placing a widget on your site that shows your popular or most recent bitmarks, or the top results from a search of all currently popular bitly links. Please visit the plug-in settings page to authorize your Bitly account. For the widget, please find 'Bitly Bitmarks' under the Available Widgets area. 5 Version: 1.0 5 Version: 1.0.1 6 6 Author: Bitly 7 7 */ … … 370 370 if ( $bitly->hasToken() ) 371 371 { 372 $info = $bitly->userInfo(); 373 error_log("Check if the token is valid on bitly", 0); 374 if ( isset($info['login']) ) 375 { 376 $validKey = true; 377 } 378 else 379 { 380 $validKey = false; 372 $bitlyError = null; 373 try { 374 error_log("Check if the token is valid on bitly", 0); 375 $info = $bitly->userInfo(); 376 $validKey = true; 377 } catch (BitlyServiceError $e) { 378 $validKey = false; 379 switch ($e->getMessage()) { 380 case 'MISSING_ARG_ACCESS_TOKEN': 381 $bitlyError = 'Please supply an access token.'; 382 break; 383 case 'INVALID_ACCESS_TOKEN': 384 $bitlyError = '<strong>Invalid access token.</strong> Please verify that you have entered your Bitly Oauth token correctly.'; 385 break; 386 default: 387 $error = $e->getMessage(); 388 $errno = $e->getCode(); 389 if ( !$error ) 390 $error = 'An unknown error occurred.'; 391 $bitlyError = "$error (Errno $errno)"; 392 } 381 393 } 382 394 } … … 408 420 <th><label for="bitly_settings-oauthToken"><?php _e( 'OAuth Token', 'bitly' ); ?></label></th> 409 421 <td> 410 <?php if ( isset($validKey) && !$validKey) { echo "<span style='color:red;'><strong>Invalid OAuth Token:</strong> Please verify that you have entered your Bitly OAuth token correctly.</span><br>"; } ?>422 <?php if ($bitlyError !== null) { echo "<span style='color:red;'>$bitlyError</span><br>"; } ?> 411 423 <input id="bitly_settings-oauthToken" name="bitly_settings[oauthToken]" type="text" 412 424 value="<?php echo bitly_settings( 'oauthToken' ); ?>" /> -
bitly/trunk/lib/BitlyService.php
r751675 r758637 19 19 */ 20 20 21 class BitlyServiceError extends Exception {} 22 21 23 class BitlyService { 22 24 … … 282 284 283 285 $response = curl_exec( $handle ); 286 287 $errno = curl_errno( $handle ); 288 if ( $errno != CURLE_OK ) 289 throw new BitlyServiceError(curl_error( $handle ), $errno); 284 290 285 291 curl_close( $handle ); … … 290 296 { 291 297 $response = @json_decode( $response, true ); 298 if ( $response === null ) 299 throw new BitlyServiceError('JSON could not be decoded', -1); 292 300 293 301 if ( 200 == $response['status_code'] && 'OK' == $response['status_txt'] ) 294 302 return $response; 303 else 304 throw new BitlyServiceError($response['status_txt'], $response['status_code']); 295 305 296 306 } -
bitly/trunk/readme.txt
r751675 r758637 5 5 Requires at least: 2.8 6 6 Tested up to: 3.5.1 7 Stable tag: truck7 Stable tag: 1.0.1 8 8 License: GPLv2 or later 9 9 License URI: … … 50 50 = How does the plugin handle previously created posts? = 51 51 52 Posts that were created prior to installing the plugin will only get a bitly short link when someone actually visits the old post. This will result in old posts showing up in your public bitly bitmark stream (https://bitly.com/u/BITLYUSERNAME) unless you have set your default bitmark privacy settings to "Private" at https://bitly.com/a/settings/saving 52 Posts that were created prior to installing the plugin will only get a bitly short link when someone actually visits the old post. This will result in old posts showing up in your public bitly bitmark stream (https://bitly.com/u/BITLYUSERNAME) unless you have set your default bitmark privacy settings to "Private" at https://bitly.com/a/settings/saving 53 54 == Changelog == 55 56 = 1.0.1 = 57 * Clarification for error messages. 58 59 == Upgrade Notice == 60 61 = 1.0.1 = 62 This updated version has error messages that are more specific. Please upgrade if you are getting an 'Invalid Token' error message during setup. 63
Note: See TracChangeset
for help on using the changeset viewer.