Provide code examples in the API documentation

 
    • tburny schrieb...
    • Forum Moderator
    • 28. Mai. 2012, 10:36

    Provide code examples in the API documentation

    I am suggesting that the API documentatation should provide code examples, especially to the authentication section.

    Often, users seem to have difficulties with the authentication part, because it is sometimes a little bit abstract and you have to read very carefully.
    Major points here are building the API signature correctly, correct encoding and url escaping of parameters and making the auth.getSession request.

    It should be easily possible to add collapsible boxes using a link like "show sample code" .
    The sample code could either be pseudocode or could be a selection of the most popular programming languages languages for the web, like PHP, JavaScript, Java and maybe Ruby and Python. One should be able to select the desired language using a dropdown box then.
    It wouldn't be too much effort, but it would help users to understand the documentation far better, as they have concrete examples and code instructions for what to do.

    What do you think?

    Combo.fm: Combine your favourite radio stations! | My Blog | scala-lastfmapi | Cache2k - A high performance Java in-memory cache
    P.S.: Do not click here
    throw new PokemonException(); //Gotta catch 'em all
    My forum post reflects my personal opinion :)
    • DaMonte81 schrieb...
    • Benutzer
    • 7. Jun. 2012, 18:14
    I agree, code examples would help greatly. Actually your example of confusion with the auth.getSession request is exactly what brings me to the forum. Thank you.

    I'm writing a desktop program and have managed to get as far as step 4. What I'd like to know is what is the proper format to fetch the web service session(sk)? I figured the actual call would look similar to the gettoken method plus the token and api_sig, but it just returns an error13.
    Here's an example of what I am apparently doing wrong:
    http://ws.audioscrobbler.com/2.0/?method=auth.getsession&api_key=xxxxx&token=yyyyy&api_sig=zzzzz

    I know need to do this before i can go on to step 5 and 6. I am a bit confused. :/

    • JRoar schrieb...
    • Alumni
    • 7. Jun. 2012, 19:24
    DaMonte81 said:
    I figured the actual call would look similar to the gettoken method plus the token and api_sig

    That is correct. In Step 6 there is an example of how to construct the signature for this exact method (auth.getSession). Feel free to open a new thread if you still have problems (and include your code).

  • [spam]

    [spam]

    Bearbeitet von bengt_bangt am 12. Jun. 2012, 13:31
    • tvalent2 schrieb...
    • Benutzer
    • 27. Jun. 2012, 21:47

    Absolutely

    I'm surprised the docs don't already have this.

Anonyme Benutzer dürfen keine Beiträge schreiben. Bitte log dich ein oder registriere dich, um Beiträge in den Foren schreiben zu können.