0

REALLY happy to see people playing with the API though. I've spent a lot of time on it this past week!!

I like it alot. But is it perfect yet?

Edited by LastMitch: grammer

0

Not yet at all. Still making lots of changes!! But I'm learning from the feedback and ideas everyone is coming up with.

0

Plus, nothing is ever going to be perfect. Nothing about DaniWeb is perfect. It can always be improved.

0

I know this has affected what some of you have written so far, and I reallllly apologize.

However, I've made a change to fetching multiple IDs at once. You now use a semicolon-delimited list as follows:

www.daniweb.com/api/members/1;67225
www.daniweb.com/api/forums/8;17;117

0

Not yet at all. Still making lots of changes!! But I'm learning from the feedback and ideas everyone is coming up with.

This is alot work! But you're having fun! This is something different. I think people might enjoy this. Once this is all set and done. The instructions plus demo will help alot, it help me so I think it will help others. I can't wait til the final product.

Why a semicolon? I got no idea what you are doing.That is something I don't see often. It stands out. If you want it that way.

0

What you can do for members instead is fetch their latest X posts and display the threads they are from

Yes, I could do that. I just searched for their 'id' within the 'posters' array.

www.daniweb.com/api/forums/8;17;117

Looks interesting.

http://www.daniweb.com/api/forums/2;1;61/articles 

Seems to work too.

I know this has affected what some of you have written so far, and I reallllly apologize.

SHould only be a line or two of code. Yep, my card game - just had to tweak the base url and the implode - so no hassle at all. :)

Q: I've very limited experience of Auth, so is it safe to place Auth into the page and then add the $access_token to the querystring for retrieving general posts?

When I include the:

    $client_id = xxxx; 
    $client_secret = 'xxx'; 
    $current_url = 'http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF']; 

    if ($access_token = $_REQUEST['access_token'])  
    {  
        // Pass your Access Token into all POST requests to authenticate yourself  
        echo 'Your Access Token for this session is ' . $access_token;

         //echo $access_token;
    } 
    else 
    { 

Even after clicking the 'Continue button' I get:

Notice: Undefined index: access_token in {my page} on line 6
Your Access Token for this session is xxxx

So the access token is retrieved, but the test throws an error.

WHen I refresh the url (with the access code in it):

{my page}?code=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx

And try:

echo 'Your Access Token for this session is ' . $access_token;

print_r(json_decode(file_get_contents("http://www.daniweb.com/api/forums/17/articles?access_token = $access_token"),true));

I get

[error] => Cachebuster detected: Please pass in an access token to retrieve non-cached results. 

??EDIT

Doh!

articles?access_token = $access_token

Had spaces around the ' = ' !
Noob mistake.

Edited by diafol

0

http://www.daniweb.com/api/forums/2;1;61/articles
Seems to work too.

No, it doesn't. You're just fetching articles that are within the Software Development category. the 1 and 61 got stripped out.

And yes, a URL cannot contain spaces. :) Really glad to see you got it working!!

Really want to encourage people trying out our OAuth implementation.

Also, the demo code provided is a hand-coded OAuth 2.0 implementation, but there are lots of existing libraries out there that do it all for you and should work.

0

OK I made the URL above return a 404 error so that it's not confusing that it doesn't work.

0

Notice: Undefined index: access_token in {my page} on line 6

It's because my demo code isn't using PHP strict. I should fix that.

You should change line 5 to:

if (isset($_REQUEST['access_token']) AND $access_token = $_REQUEST['access_token'])
1

No, it doesn't. You're just fetching articles that are within the Software Development category. the 1 and 61 got stripped out.

Even though it wasn't a feature, you've inspired me, and now it is one. :)

0

Great - it's really becoming feature rich :)

If I could just get the OAuth to work...

I think I'm missing the point here. For example, say I want to host an app (like the Box example I posted earlier) of a webpage, in order to use OAuth, I need to supply my membership number and secret key, right? But I shouldn't allow others to use the page then or what?

How would others use the page? They'd have to supply their own details? I'm mightily confused - as I say, I've very limited experience of OAuth.

Edited by diafol

1

Basically what you do is you supply your membership number and secret key into the PHP code. When you pass in your membership #, this is not used for the credentials of the end-user who uses the app. It's simply used so that I know who the author of the app is, so if you do any funny business like create an app that downvotes a million members, I know who to ban.

What will happen is when an end-user visits your webpage, they'll be quickly redirected to a form asking if they authorize diafol to have access to their account. If they click accept, then they'll be redirected back to your webpage, and you'll gain access to a token which can be used to access their account.

0

Diafol, are you still having trouble? I thought you were able to get it done when you realized you had the spaces around the equals sign?

0

If you were able to get the live demo example to work, then the $output array (where it prints $output['username'] to say hi to you) will be an array of your information when you access the page, an array of my information when I access the page, etc.

0

Hi Dani, thanks for that. I'm afraid I haven't been able to work on it as I'm back to work tomorrow with about 60 books to mark! Never leave things to the last minute!

What will happen is when an end-user visits your webpage, they'll be quickly redirected to a form asking if they authorize diafol to have access to their account. If they click accept, then they'll be redirected back to your webpage, and you'll gain access to a token which can be used to access their account.

Okayy, I think I got that. So an user needs to be logged into DW in order for them to use the app. Right, I'll have a look soon (probably in a few days judging by the height of unmarked books still facing me).

0

Good luck marking!

So an user needs to be logged into DW in order for them to use the app.

When a user first accesses your app, they'll be temporarily redirected to our OAuth page, in which one of three things will happen:

  • If they're already logged into DaniWeb, they'll be asked to authorize that your app can access their account, and then they'll immediately be redirected back to your app.
  • If they're already logged into DaniWeb, and they've previously authorized your app, then the entire process is transparent to them, and they'll immediately be directed back to your app without realizing they ever left.
  • If they're not logged into DaniWeb, they'll be asked to join or login, and once they do, then they'll immediately be redirected back to your app.
0

I think your issue might have been related to a bug I recently introduced and subsequently recently fixed.

0

There's now full JSONP support which means you can authenticate entirely client-side with Javascript/jQuery. Check out the new Javascript demo example. :)

0

There's now full JSONP support which means you can authenticate entirely client-side with Javascript/jQuery. Check out the new Javascript demo example. :)

It's looks nice and much better than regular one because of the animate button and new window.

I'm bit overwhelmed with that much updates.

I guess now everyone in order to used JQuery they much have this:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>

?

Edited by LastMitch: grammer

1

Yes, jQuery is required.

However, they each serve different purposes. One is serverside and the other is clientside. It depends what your application does to determine which one you will need.

0

Dani, maybe you should add the API announcement/link to API in your sig because it seems that the link posted on the very first page is broken?

Edited by ~s.o.s~

0

I changed the link on the first page, but I'll also go ahead and add it to my sig.

0

riahc, I can't run your program because it says I don't have the latest version of .NET. Plus, I'm on a mac.

Yes, its a C# program. You will have to install Mono and Im not sure if its supported. I complied this in VS2012 so you need the 4.5 framework.

The screenshots is pretty much all there is to it. Nothing else.

Its only purpose is to show the compatibilty between C# and your API.

Once I understand OAuth, Im problably going to work on a posting app.

0

BTW, if someone wants the source code, Ill put it up as well with some comments :) although its very sloppy

@Riahc3, I'll take you up on that offer ;)

0

@Riahc3, I'll take you up on that offer ;)

OK, ill tidy it up a bit and put some slight comments.

Remember this is a proof of concept; The code is very dirty and "as is".

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.