Trying to find a working example of bit.ly API, Wordpress plug-in errors

428 views
Skip to first unread message

Kent Bye

unread,
Jan 13, 2014, 10:59:40 PM1/13/14
to bitl...@googlegroups.com
I am trying to find a working example of integration of the bit.ly API integration. The Wordpress appears to be broken. The Drupal module doesn't seem to be working at the moment. And I can't get confirmation as to whether or not the client_id and client_secret keys are still being used anywhere since I can't seem to find out where to generate them on the new dev site, and the link that the Falicon/BitlyPHP GitHub code points to is being redirected.

Much more details down below.

I tried installing the bit.ly plug-in on a fresh local install of Wordpress and got a white screen of death when going to the homepage or trying to create a new post. The errors are down below.

One thing that I noticed in the Wordpress settings is that you're just requesting a single Wordpress OAuth token that is generated from https://bitly.com/a/wordpress_oauth_app

What is confusing is that I keep seeing references to a client_id and client_secret in different API integrations, but I can't seem to find where to generate these.

For example, the documentation at http://dev.bitly.com/authentication.html says: 
  • Register your application here -- your application will be assigned a client_id and a client_secret.  

But going to that link only provides the Generic Access Token, and it's unclear whether the client_id is my username and whether client_secret is the Generic Access Token. When using it in this way with the Drupal module, then it didn't work.

I installed the Drupal bitly module via https://drupal.org/project/bitly and then went to the /bitly_oauth path provided by the Drupal module, but it gave me this error:
{"status_code": 500, "data": null, "status_txt": "INVALID_CLIENT_ID"}

I suspect that using my bitly username is not the same as the client_id. But I'm not able to figure out how to get it.

This how-to blog post shows the process of registering a bit.ly app, but it appears as those this links have changed and this process deprecated: http://cgeers.com/2012/04/21/bitly-api-authentication/

The Falicon/BitlyPHP GitHub code points to http://bit.ly/a/account in order to get the bitlyKey, bitlyLogin, bitly_clientid, and bitly_secret -- However, this URL has been redirected to https://bitly.com/a/settings, which doesn't show how to get the client_id or client_secret.

I turned on the debug flag in Wordpress to show the errors that I'm getting, which are shown down below.

I'd appreciate any guidance and pointers to an integration that is currently working, and specific URLs to go to in order to generate all of the access information.

Thanks
-Kent.

ERRORS ON THE HOMEPAGE AFTER INSTALLING THE BITLY WORDPRESS PLUGIN

Notice: Undefined index: file in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php on line 95

Notice: Undefined index: file in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php on line 101

Notice: Undefined index: file in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php on line 108

Notice: Undefined index: file in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php on line 113

Fatal error: Uncaught exception 'BitlyServiceError' with message 'INVALID_URI' in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/lib/BitlyService.php:309 Stack trace: #0 /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/lib/BitlyService.php(66): BitlyService->get_bitly_service('shorten', Array) #1 /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php(269): BitlyService->shorten('http://localhos...', 'bit.ly') #2 /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php(244): Bitly->get_bitly_link('http://localhos...', 4) #3 /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php(60): Bitly->get_bitly_link_for_post_id(4) #4 [internal function]: Bitly->og_tags('') #5 /Users/kentbye/Sites/wordpress/wp-includes/plugin.php(429): call_user_func_array(Array, Array) #6 /Users/kentbye/Sites/wordpress/wp-includes/general-template.php(1634): do_action('wp_head') #7 /Users/kentbye/Sites/wordpress/wp-content/themes/twentyfourteen/header.php(30): wp_head() #8 /Users/kentbye/Sites/wordpress/w in/Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/lib/BitlyService.php on line 309


ERRORS ON THE NEW POST PAGE AFTER INSTALLING THE BITLY WORDPRESS PLUGIN

Notice: Undefined index: file in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php on line 95

Notice: Undefined index: file in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php on line 101

Notice: Undefined index: file in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php on line 108

Notice: Undefined index: file in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php on line 113

Warning: Cannot modify header information - headers already sent by (output started at /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php:95) in /Users/kentbye/Sites/wordpress/wp-includes/option.php on line 563

Warning: Cannot modify header information - headers already sent by (output started at /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php:95) in /Users/kentbye/Sites/wordpress/wp-includes/option.php on line 564


AND

Notice: Undefined index: file in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php on line 95

Notice: Undefined index: file in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php on line 101

Notice: Undefined index: file in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php on line 108

Notice: Undefined index: file in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php on line 113

Fatal error: Uncaught exception 'BitlyServiceError' with message 'INVALID_URI' in /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/lib/BitlyService.php:309 Stack trace: #0 /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/lib/BitlyService.php(66): BitlyService->get_bitly_service('shorten', Array) #1 /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php(269): BitlyService->shorten('http://localhos...', 'bit.ly') #2 /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php(244): Bitly->get_bitly_link('http://localhos...', 8) #3 /Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/bitly.php(141): Bitly->get_bitly_link_for_post_id(8) #4 [internal function]: Bitly->hook_get_sample_permalink_html('<strong>Permali...', 8, NULL, NULL) #5 /Users/kentbye/Sites/wordpress/wp-includes/plugin.php(199): call_user_func_array(Array, Array) #6 /Users/kentbye/Sites/wordpress/wp-admin/includes/post.php(1098): apply_filters('get_sample_perm...', '<strong>Permali...', 8, NULL, NULL) #7 /Users/kentbye/Sites/w in/Users/kentbye/Sites/wordpress/wp-content/plugins/bitly/lib/BitlyService.php on line 309


James Socol

unread,
Jan 17, 2014, 10:26:13 AM1/17/14
to bitl...@googlegroups.com
Hi Kent,

On the page where you can find the generic access token (https://bitly.com/a/oauth_apps) click the "Register an app" link toward the top, that will take you through the process of registering an app and getting a client_id and client_secret.

As you gathered, the Bitly login is not the same as a client ID. There are 5 pieces of information here that are important for OAuth applications:

Associated with the application itself:
* client_id
* client_secret

Associated with the user:
* username
* password (though for most web-based OAuth applications you will never need this from the user)

Associated with the user and the application:
* Access token

Once a user has authorized the application and you've generated an access token, that is the only authentication information you need to include in the request.

A great place to start with OAuth and the concepts is http://oauth.net/.

James
Reply all
Reply to author
Forward
0 new messages