Member Avatar

Hi all, following a chat with Dani, I'm just posting an example of a jQuery OAuth implementation. Major updates to come over the next weeks and months, but it's a start. I'll be publishing the code once I've cleaned it up and de-noobified it somewhat. :)

I get a 500 server error :(

Member Avatar


Yep, I was having issues with GETTEXT, so had to swap a few include files around - but I got them in the wrong order!

I love the Twitter Boostrap look!! Spiffy!!

Member Avatar

Thanks for the heads up. I didn't know about the include_self! OK, I just hope I get the same json format :)

OK, I just hope I get the same json format :)

You will! However, it seems like it isn't able to determine the forum name when you're in a sub-forum, like one of the sub-forums within Microsoft Windows. Are you sure you're pulling descendants and not just children?

Member Avatar

Ok, I've added the parameter - does it work for you now?

Member Avatar

OK, I'll hard code your fave forums into my code and see if I can replicate the problem.
Hmm, it's stopped working - can't splice the json - did you change anything?

Ah - I now see the "0": etc 'keys'

I didn't change anything????

Oh shoot, you're right! I did break something!! Fixing ......

Fixed. Sorry about that.

Don't ya just love working with a moving target API? :)

GRR, not fixed ... hold on :)

NOW fixed.

Member Avatar

OK, you've officially given me a freaking headache. :)
He he.

I was trying to add pagination and I accidentally put the pagination object inside the data object ... All good now.

Member Avatar

OK, I think I tracked down the problem. If you have a top-level forum as your favourite, then children don't get taken into account in my code, so although the posts will be extracted, the program can't identify the forum as it has no id-title array item. OK, that went totally over my head until now. I've been beating my head against a wall as to why Forum 10 kept showing an undefined title. :)

//OK I think I've sorted it now - that was horrible :( Managed to sort it without a recursive function - but will probably need to do that to tidy up the code.

I extracted json from the nested forums (without descendants and include_self) as that allowed me to search children easily (nested loops).

Member Avatar

aw. i think you're right. my comparison top get the titles used the original favourite forums - that's why I wasn't getting the child forums. DOH! and DOUBLE DOH! Thanks.

Favorite forums have always been the same. It's just an array of forum IDs within /me. Just take that array of forum IDs and collapse it into a semi-colon delimited list, and fetch all those forums and all their descendants at once.

Member Avatar

That's what I did:

ff, myForums are global vars (array)

    $.getJSON('' + access_token + '&callback=?').done(function(json){
        me =;
        $.each(, function(i,v){
        forums = ff.join(';');
        $.getJSON(''+ forums + '/descendants?include_self=1&access_token=' + access_token + '&callback=?').done(function(json){

                myForums['f' +] = v.title;

Hopefully, it's fixed :)

OK yeah, that should work :) Much more elegant than going through nested loops.

Just tested it and i'm seeing Windows Vista nd Win 7/8 and Windows 2000/XP ... seems to all be working now :)

Member Avatar

Yipee! OK, I think I'm gonna leave it there on that particular app.

BTW - if I want to place more that one app on one site, should I create a new application for each or should I just use the one and reuse the same client id etc?

BTW - if I want to place more that one app on one site, should I create a new application for each or should I just use the one and reuse the same client id etc?

It's up to you with two caveats:

  1. If you use clientside OAuth 2.0, the domain registered must match the domain the app resides on.
  2. The application name and website is displayed when asking for authorization from end-users, so you'll want it to be a friendly name. Whether you create a single app or multiple apps from the same domain name would depend purely on end-user usability. There's no advantage or disadvantage.
Member Avatar
  1. Yep
  2. I didn't think of the name presented to the public :) Good job I didn't name it something profane!


I like that you included documentation now! :)