sample code

hi,

the link posted inside "Help with authentication" has been removed. can anyone please post any sample code which does authentication / posting once again?

thanks!
Tagged:

Answers

  • sorry, don't have code on me right now to post, but i can detail out the process (be aware, this is on an older version of vanilla, i have not worked with the newer version as of yet)

    all the calls that need authentication require having a transient key, you can get that by making a call to this controller: https://github.com/eleith/vanilla-api-addon/blob/master/controllers/class.sessioncontroller.php

    so basically, after the user has logged in (or you have some sort of single sign on implemented), make a call to

    /api/session

    what you get back is the users transientkey. (a generated string that will work for that session)

    then make a call to any other controllers and pass that key in

    /api/discussion/add (POST:Discussion/CategoryID, Discussion/Body, Discussion/Name, Discussion/TransientKey)

    the above are the key values you need to pass in form that call, you can see the other apis supported here: https://github.com/eleith/vanilla-api-addon

    sorry, this is not fully documented, i don't use it anymore so haven't had the need. i don't even know if it works with recent versions of vanilla. feel free to push updates if you want to better document it!
  • There is a native api for most things.
    http://vanillaforums.org/docs/api

    grep is your friend.

  • True, but adding to a discussion is not part of the native API (at least, according to that page).
  • x00x00 MVP
    edited October 2011
    What I'm saying is it would be better to extend that

    why not use

    GET /post/discussion

    pick up transient key then

    POST

    /post/discussion

    That is the whole point of mating MCV with REST. It is not really REST if the resources are in different places.

    grep is your friend.

  • Agreed - Extending the current API would be fantastic (I just posted a question in the forums about that). Have you looked into doing that or do you know someone who is working on it?
Sign In or Register to comment.