Please upgrade here. These earlier versions are no longer being updated and have security issues.
HackerOne users: Testing against this community violates our program's Terms of Service and will result in your bounty being denied.

Json API - What does it do?

edited September 2010 in Vanilla 2.0 - 2.8
What exactly does JSON API do? If I set it up then would it be possible for a Twitter app to be created that would automatically post users tweets to the forum under their name?
Tagged:

Comments

  • this application makes certain URLs available that allow for another program to interact with the data in Vanilla. All the URLs output JSON.

    for example, say you want another webpage to list out all the categories in your blog. once you install this application, navigate to /api/category and all your categories will be output in JSON output.

    this makes the data easily consumable by any programming environment you may be working in (python, javascript, java, c++, etc etc...)

    most of the APIs are read only, but there are also two write-enabled APIs. here is the list of available APIs and the optional GET (read only) and POST (writable) params that are accepted by each

    /api/category
    /api/discussion (GET: id, limit, offset)
    /api/discussion/add (POST:Discussion/CategoryID, Discussion/Body, Discussion/Name, Discussion/TransientKey)
    /api/comment/add (POST: Comment/DiscussionID, Comment/CategoryID, Comment/Body, Comment/Name, Comment/TransientKey)
    /api/session
    to answer your second question, i think that would be difficult as the internal authentication code for vanilla relies on cookie session data. as you can see, i have an api/session call which is used to grab the users current session and that information is passed as transientkey into the comment/add and discussion add calls.

    you would have to do a bit more hacking to be able to have an external application make such calls on behalf of a user that does not have a current vanilla session.

    hope this helps!
  • I am having a problem with the session api. I cannot get it to print using php as well as the information it's returning changes for some reason.

    I am basically just asking to be pointed in the right direction to be able to learn how to properly use the json api. All things I'm finding require the .json file and there isn't one here.
  • not sure i follow your question exactly, but i'll give it a shot.

    download the application and then look at /api/controllers/class.sessioncontroller.php

    you'll see some very basic code on how to access the currently logged in users session and how to read their transientkey.

    if you look at /api/controllers/class.commentcontroller.php you will see how passing in the transientkey allows the controller to make post requests on behalf of the user.

    for my use case, i use an ajax request to read from /api/session to grab the transient key, and then i post on behalf of a user wanting to create a new discussion or add a comment along with the transient key to something like /api/add

    hopefully that was helpful?
  • Hi eleith, would this addons allow you to replace the comments in a Wordpress article with Vanilla?
Sign In or Register to comment.