0

What harm would come of a client firing mass get requests at the server?

A client firing mass GET requests at our API would actually be less resourse intensive than a client firing mass GET requests at the main site (which they could do) because the API is so heavily cached. And probably not any more harm from the DoS attacks we get on a very regular basis. Our network sits behind a load balancer that distributes requests across a handful of web servers, and is well protected, thanks to James #1 :) You'd really need to put a lot of effort in to hurt us.

0

AWESOME!!

And please use the OAuth code at http://www.daniweb.com/api/demo/javascript

That one should not have the popup blocker issue. Web browsers kill the popup if it is not user-initiated. That code launches the popup upon clicking a link whereas the code on the documentation page launches the popup automatically on page load.

0

Fair enough :) Thought I would ask anyway, felt stupid for even managing to make that infinite loop occur in the first place :D

1

Diafol, there's a 404 error clicking on the first post of the thread. It's not parsing the $url variable.

Also, moving forward, so that this thread doesn't get infinitely long, start a new thread about your app so we can discuss your specific app, and use the daniweb-api tag. All threads, code snippets and tutorials tagged with daniweb-api are being linked to directly from our API homepage, so that it will be easy for folks to find ports in different languages, different apps available, etc.

0

Also, moving forward, so that this thread doesn't get infinitely long...

Good idea. I was just tinkering though. I'll get busy with it over the coming weeks.

Diafol, there's a 404 error clicking on the first post of the thread. It's not parsing the $url variable.

Doh! Forgot to change the php var to the 'uri' item. Fixed! Will look at OAuth again.

Thanks Dani.

Edited by diafol

0

New Q:

A little confused over the nested forums json output for:

http://www.daniweb.com/api/forums/descendants?nested=true

{
    "title":"Web Development",
    "description":"Our Web Development forum category encompasses everything related to building a website from the ground up. Topics include serverside scripting,  clientside scripting, databases, and web \/ graphic design. Please only link to your website if it is necessary to demonstrate how something isn't working.",
    "replies":"2152",
    "articles":"743",
    "subforums":[
     {
      "title":"PHP",
      "description":"Our PHP forum is the place for Q&A-style discussions related to this popular development language.  LAMP programmers will appreciate our separate Apache forum, within the Networking sub-category of the Hardware and Software category, and MySQL forum, also within the Web Development category.",
      "replies":"143877",
      "articles":"28346",
      "uri":"http:\/\/www.daniweb.com\/web-development\/php\/17",
      "id":"17",
      "last_post_timestamp":"1361514838",
      "relatives":{
       "parent_id":"31",
       "ancestors":[
        "17",
        "31"
       ],
       "children":[
        "17"
       ]
      }
     },

I was expecting an 'id' for the parent (Web Deveopement) in this case, but it only seems to show in the subforums array.
I don't understand why the PHP 'relatives' would have its own id (17) in there.
Just I was looking to redo the forum dropdown from the api as opposed to hard coding it. The structure above makes it difficult AFAICS to 'loop and store' as you need to go fishing for the top parent id. Using

http://www.daniweb.com/api/forums?nested=true

Gets some degree of nesting, but without the subforum names.
Any advice?

Edited by diafol

0

If you're familiar with PHP, why don't you begin by getting it to work perfectly in PHP and become familiar with it? Then move on to C#. Also, if you have a lot of Javascript experience, check out the JS-based implementation.

First get the ones that are just copy/paste from our demo to work before moving on :)

Have you read the Step-by-step instructions in the left column next to the code on the Documentation page? That should shed some light.

Well you made already PHP examples so thats pretty easy to follow. Never worked with cURL though.

I dont have much JS expirence and the expìrence I have, I hate it as a language. I think anything with "J" or "Java" in its name, I basically hate :(

Ive perfered to soley concentrate on desktop clients when it comes to the API.

0

Diafol,

http://www.daniweb.com/api/forums/descendants?nested=true

The 'id' for Web Development does exist. It's just listed after the subforums array. In other words, the rest of the properties for Web Development appear after the subforums property (uri, id, last_post_timestamp, etc). You just needed to scroll down a bit. It might be less confusing to convert the JSON into a PHP array and do a var_dump() so that you can get a better idea of how it's laid out. All forums include all the same list of properties regardless of what level they are at.

I don't understand why the PHP 'relatives' would have its own id (17) in there.

The array of ancestors starts with a forum's own ID and works its way up the chain. The array of children starts with a forum's own ID and then lists its children. This was done out of convenience for some of my own uses, so I left it in the hopes that you would find the same value.

http://www.daniweb.com/api/forums?nested=true

You're not getting any of the subforums because you're not pulling any descendants. You're just pulling the top-level categories.

For example, http://www.daniweb.com/api/forums/2 will pull just the Software Development category, while http://www.daniweb.com/api/forums/2/children will pull a flat list of Software Dev + its immediate children, http://www.daniweb.com/api/forums/2/descendants will pull a flat list of Software Dev + its immediate children + children's children (aka all descendants) and http://www.daniweb.com/api/forums/2/descendants?nested=1 will pull a nested list that utilizes the subforums property to illustrate hierarchy.

Well you made already PHP examples so thats pretty easy to follow.

The reason I am suggesting that you start with PHP is because you seem to be confused by the concepts in OAuth. Since it doesn't seem you have a lot of OAuth experience, it might be best to start with something that exists and build upon it so that you can get a better grasp of the concepts before porting it to a different language.

0

The 'id' for Web Development does exist.

Sorry, my bad. Scrolling down on a shed full of subforums must have escaped me :)

You're not getting any of the subforums because you're not pulling any descendants.

No I realise that, just that the subforum ids are listed but not the related name. No prob. Now that I know the parent id is listed for the nested descendants, everything should be fine.

0

No I realise that, just that the subforum ids are listed but not the related name.

If you need information about the subforums (such as their name), then you need to use either /children or /descendants. If you don't care about the subforums, then leave them off.

0

Are you sure that the jquery oauth works? The example code runs when on Daniweb (the link you provided), but when I try to run the same code on my local machine, no access token is returned - I get the popup, but I don't get the return access token and the resulting message. No point posting the code as it's the same as the link.

Any ideas?

//when I place the code in a new file, it asks for permission etc, but I don't get the access code / show code.

//EDIT
SO the client_id is like the app# - nothing to do with the member_id#. It now works after resitering the app. Doh!

BTW - any way of deleting the app? I just get the option to add a new one - no way to edit or delete.

Edited by diafol

0

Diafol, did you get it working? You need to register your application, and, as a security measure, it checks to make sure the request is coming from the same domain as you registered. This is because no secret is used with the clientside version (because it wouldn't be much of a secret if it was in the HTML code!)

There's currently no way to edit or delete apps. There will be in the future. There is no harm from them hanging around. :)

Edited by Dani

0

http://dw.diafol.org/jsonp.php

There's the link to the OAuth version. Although it works for me, I obviously can't test it as somebody else. Interesting problem I had with the usernames like <MICHAEL> - had to html encode the titles and usernames, otherwise parsed as html! Don't look too closely at the underlying code - it's a mess! Just trying to get it to work - not making it pretty ;)

1

Tested it for you diafol, it logs in correctly etc authorising as myself (When I was already logged into Daniweb). Still had your member ID as the default though :( Should get that when you authorise and default to whoever is using :) Just a suggestion :D Else works fine as far as can see

Votes + Comments
thanks
0

Great - thanks Mikey! Good suggestion - I will see to it.

//EDIT

OK, done - user now selected automatically. PS I hate scoping in js. Horrible.

Edited by diafol

0

I think that if you're logged in, it should pull only threads in your favorite forums instead of all threads. You can do this by simply adding ?filter=recommended when fetching the articles.

0

Another suggestion: I understand that you have to have the 'Click Here' link because popup blockers will block the popup if they're not user-initiated. However, how about instead going into the page right away and binding the popup to the 'Update' button.

0

I think that if you're logged in, it should pull only threads in your favorite forums instead of all threads. You can do this by simply adding ?filter=recommended when fetching the articles.

Yes, that's on the cards - I was thinking that after Mikey suggested the pull on the member id. Thanks for the advice.

Another suggestion: I understand that you have to have the 'Click Here' link because popup blockers will block the popup if they're not user-initiated. However, how about instead going into the page right away and binding the popup to the 'Update' button.

Again, I was thinking of how to do that - the 'click here' button is obtrusive and hiding/showing is a little flaky. Will get on it. :)

//EDIT

OK, all-in-one update button working :)
Now to reformat the fetch routine for articles.

Edited by diafol

0

http://www.daniweb.com/api/forums/descendants

This seems to be returning a strange format. Even with nested set to 0/false.

It seems to get 5 'top level' forums including a 'blank' forum

It starts:

{
 "data":[
  [
   {
    "forumid":"1",

Seems as if it's not a flat list as suggested in your previous post.

Just trying to get all forums -> id, title into a flat array. I must be doing something wrong :(

0

No, it is a flat list (aka all forums are at the same level), but it's an array of an array, and all of the forums are at the second level deep.

It's done like that on purpose. For example:

http://www.daniweb.com/api/forums/8

array => (
    array => (
        forum 8
    )
)

http://www.daniweb.com/api/forums/8;9

array => (
    array => (
        forum 8
    ),
    array => (
    (
        forum 9
    )
)

This way, when multiple forums are passed in, children/descendants of each of them are in separate arrays.

http://www.daniweb.com/api/forums/8;9;1/children

array (3) => (
    array (1) => (
        forum 8     // C++ forum has no children
    ),
    array (1) => (
    (
        forum 9     // Java forum has no children
    )
    array (7) => (
    (
        forum 1,     // Hardware & Software has children
        forum 99,
        forum 12,
        forum 7,
        forum 11,
        forum 13,
        forum 98
    )        
)

If you don't specify a list of forums, the list of forums is preset to be the top level categories, so it follows the same rules as if you had specified forums.

The reasoning is to keep everything at the same level regardless of what is or isn't passed in.

0

I understand the specified forums, but without specifying... There was some strange stuff at the bottom, but this looks different now:

{
 "data":[
  {
   "forumid":"1",

Compared to:

{
 "data":[
  [
   {
    "forumid":"1",

from earlier.

Did you change something??

0

Diafol, you're going to get the latter when you specify /children or /descendants. You're going to get the former if you just want to pluck specific forums.

1

I'm about to head out, but there are six items in the data array, each corresponding to our six top level categories. Then, you need to drill down for all the forums within them.

Check this out: http://jsonviewer.stack.hu/#http://www.daniweb.com/api/forums/descendants

Click on the 'Viewer' tab.

Also, please start a NEW QUESTION and tag it with daniweb-api so that this thread doesn't get ridiculously long-winded with 1000 different questions that can't be found again later.

Votes + Comments
Nice link, that's a bookmark! ;)
1

Waiting for the java version of the API...When can i expect a java version?

Daniweb API is web based (or more technically a RESTful) API and as such doesn't require a language specific version of it. It's HTTP all the way. All you need to use the API in Java is a HTTP client library (like Apache HTTP Client), a JSON library like Jackson and you should be good to go. If you are still unclear about the concepts, search around for "java rest client" or something along those lines.

Edited by ~s.o.s~

0

Harinath, as Sanjay says, the API is language-agnostic, meaning that it is fully functional with any language that is capable of making HTTP requests.

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.