Code Monkey home page Code Monkey logo

vanilla-api's Introduction

Vanilla API

Vanilla API

Extensible RESTful API shim for Vanilla that operates in JSON or XML. Supports JSONP and CORS.

Getting started

To get started using Vanilla API, either:

$ git clone https://github.com/kasperisager/vanilla-api.git api

When you've done this, make sure the newly created folder is named api and not vanilla-api. Now simply go to your dashboard, enable Vanilla API in the "Applications" menu and you're all set!

How does it work?

Vanilla API is a shim that implements a RESTful URI scheme upon with you can invoke different methods using the standard GET, POST, PUT and DELETE HTTP verbs. The API then translates and redirects your request to the corresponding application controller which in return caries out the requested method.

Documentation

You can find documentation on how to use, configure and extend Vanilla API in the Wiki.

License

Copyright © 2013-2017 Kasper Kronborg Isager. Licensed under the terms of the MIT License

vanilla-api's People

Contributors

hgtonight avatar kasperisager avatar ryacobi avatar tomusm avatar tomusm-bsoft avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

vanilla-api's Issues

EDit Discussion and New Comment API not Working

  1. When I am calling Edit discussion API
    {domain}/api/discussions/1/comments?authparameters

I am calling API with administrator credentials so What might be the reason for following error?

edit-discussion-error

  1. When I am calling Add comment
    {domain}/api/discussions/33/comments?authparameters
    add-comment-error

  2. When I am calling my discussion api
    {domain}/api/discussions/mine?authparameters
    discussion-mine

Is there anything wrong with discussions controller?

  1. Is there any API for Login which can let the user sign in app with their credentials?
    I am using signature based authentication.My authentication is valid as It work for all other APIs.

I appreciate your suggestions. I got active in Vanilla forum and your addon for developing my mobile app based on vanilla forum.

I am developing mobile application using your addon.

Unable to use multiple numeric arguments

It is currently impossible to create and endpoint that makes use of two named numeric values. E.g. PUT /discussions/:id/tags/:tid will map to PUT /discussions/:id/tags/:id.

I am looking to create (via PUT) and remove (via GET) relationships between objects like this. Is this the wrong way of thinking within a RESTful API?

Error when activating api application

I get an error about how it cannot find the API_Engine class (called from the class.hooks.php file). Problem is that the class is declared as APIEngine.

Second page of discussion

How get second page of discussions?
When I use {{domain}}/api/discussions/:id I only get first page.

Can't get update user endpoint to work using cURL

Hi Kasper,

I'm testing out vanilla forums/the api to see if it will fit my use case. In the course of that, I tried updating a user through the api, and I can't get it to work; I receive a 400 response that says "You must select at least one role." I'm definitely including an array of role IDs.

I'm running vanilla locally (using MAMP). I can successfully update a user through the api using Postman (I also tried RESTClient just for kicks, and it worked as well), but I haven't been successful using cURL in either a PHP script or from the command-line (Mac OS 10.7, curl version 7.21.4).

Here's what I did from the command-line:

curl -v -X PUT -H "Content-Type: application/json"  '{"Name":"test","Email":"[email protected]","Password":"password","RoleID":[8]}' "http://localhost/api/users/3?username=[username]&timestamp=[timestamp]&token=[token]"

And this is the response I get:

{
  "AllowEditing": true,
  "User": {
    "UserID": "3",
    "Name": "test",
    "Photo": null,
    "Title": null,
    "Location": null,
    "About": null,
    "Email": "[email protected]",
    "ShowEmail": "0",
    "Gender": "u",
    "CountVisits": "0",
    "CountInvitations": "0",
    "CountNotifications": null,
    "InviteUserID": null,
    "DiscoveryText": null,
    "Preferences": null,
    "DateSetInvitations": null,
    "DateOfBirth": null,
    "DateFirstVisit": "2015-03-11 00:12:27",
    "DateLastActive": "2015-03-11 00:12:27",
    "LastIPAddress": "127.0.0.1",
    "AllIPAddresses": null,
    "DateInserted": "2015-03-11 00:12:27",
    "InsertIPAddress": "127.0.0.1",
    "DateUpdated": "2015-03-13 06:00:48",
    "UpdateIPAddress": "127.0.0.1",
    "HourOffset": "0",
    "Score": null,
    "Admin": "0",
    "Confirmed": "1",
    "Verified": "0",
    "Banned": "0",
    "Deleted": "0",
    "Points": "0",
    "CountUnreadConversations": null,
    "CountDiscussions": null,
    "CountUnreadDiscussions": null,
    "CountComments": null,
    "CountDrafts": null,
    "CountBookmarks": null,
    "_CssClass": "",
    "ConfirmEmail": 1
  },
  "Roles": {
    "2": "Guest",
    "3": "Unconfirmed",
    "4": "Applicant",
    "8": "Member",
    "32": "Moderator",
    "16": "Administrator"
  },
  "UserRoles": [

  ],
  "Code": 400,
  "Exception": "You must select at least one role."
}

I get the same response when I use cURL in PHP. I haven't been able to find any differences between the Postman client and what I'm doing in cURL. I'm definitely supplying user roles; I have a suspicion that the error message is a red herring.

I've tried recreating every single insignificant header, triple-checking the json...I can' t understand why my cURL request isn't working. Have you experienced this? Can you successfully update a user via the api with cURL, either from the command-line or PHP?

Api requests 404;

Still can't get it work; api is loaded; but haven't process any requests;
As I can see there is a problem in class.hooks.php on line 50;
cuz after APIEngine::SetHeaders($Request); I have nothing

Author who posted new comment isn't visible after posting new comment

When I post a new comment in a discussion via the RESTful API, the comment is visible in the discussion itself. But on the frontpage/mainpage of the forum I don't see the author of the last comment, I only see the second last comment author.

Can it be that when posting a new comment in a discussion there is some other logic which needs to be added in the RESTful API, so the frontpage/mainpage of the forum shows the last comment author?

HTTP_CONTENT_TYPE error

hi,
the HTTP_CONTENT_TYPE is no longer supported as per the CGI/1.1 specification so I change to $type = static::getServerArguments('CONTENT_TYPE');

but the return value displays all the html pages, and no luck of posting the body

Which version of Vanilla to use with your API

Hi Kasper,

I have downloaded and installed the develop branch and enabled your API (0.3.0), however on calling post methods it gets into an infinite loop of dispatch calls

[Wed Jan 28 22:44:00.282126 2015] [:error] [pid 20465] [client 127.0.0.1:38676] PHP 89. Gdn_Dispatcher->Dispatch() /srv/eci-mgt/vanilla/library/core/class.dispatcher.php:372
And what really makes me curious:

To resolve this it helps to create a category via the dashboard :(

Any clue what might cause this? Or which branch / version of vanilla are you proposing to use best with your api?

br
Thomas

PS: Its kinda reproducable....

"Something wrong" happens on enable

So... I've repeated this process 4 or 5 times just to make sure. I download either Vanilla Forums 2.2.3.4 or Vanilla Forums 2.2.3.6, install it, download api 0.4.0, copy it, open the admin dashboard, enable api application and BAM! "Something has gone wrong." Forum unusable forever. Repeat.

EDIT: Managed to get a backtrace:

Call to unknown method 'Gdn_Request->requestUri'
The error occurred on or near: D:\xampp\htdocs\vanilla-Vanilla_2.2.3.4\library\core\class.request.php

128:          $PassedArg = (is_array($Args) && sizeof($Args)) ? $Args[0] : NULL;
129:          return $this->_EnvironmentElement(strtoupper($Matches[2]),$PassedArg);
130:       }
131:       else {
132:          trigger_error("Call to unknown method 'Gdn_Request->{$Method}'", E_USER_ERROR);
133:       }
134:    }
135: 
136:    /**

Backtrace:

D:\xampp\htdocs\vanilla-Vanilla_2.2.3.4\library\core\class.request.phpPHP::Gdn_ErrorHandler();
[D:\xampp\htdocs\vanilla-Vanilla_2.2.3.4\library\core\class.request.php:132] PHP::trigger_error();
[D:\xampp\htdocs\vanilla-Vanilla_2.2.3.4\applications\api\library\class.apiengine.php:304] Gdn_Request->__call();
[D:\xampp\htdocs\vanilla-Vanilla_2.2.3.4\applications\api\library\class.apiengine.php:304] Gdn_Request->requestUri();
[D:\xampp\htdocs\vanilla-Vanilla_2.2.3.4\applications\api\settings\class.hooks.php:57] APIEngine::getRequestUri();
[D:\xampp\htdocs\vanilla-Vanilla_2.2.3.4\library\core\class.pluginmanager.php:724] APIHooks->Gdn_Dispatcher_beforeDispatch_handler();
[D:\xampp\htdocs\vanilla-Vanilla_2.2.3.4\library\core\class.pluginmanager.php:657] Gdn_PluginManager->CallEventHandler();
[D:\xampp\htdocs\vanilla-Vanilla_2.2.3.4\library\core\class.pluggable.php:144] Gdn_PluginManager->CallEventHandlers();
[D:\xampp\htdocs\vanilla-Vanilla_2.2.3.4\library\core\class.dispatcher.php:189] Gdn_Pluggable->FireEvent();
[D:\xampp\htdocs\vanilla-Vanilla_2.2.3.4\index.php:46] Gdn_Dispatcher->Dispatch();

Variables in local scope:

[Method] 'requestUri'
[Args] array (
)    
[Matches] array (
 )

Endpoint for latest comments

It would be nice if there was an endpoint where you can retrieve the latest comments (overall, placed anywhere on the forum).

Unable to get it to work

I have installed the api application on a "self hosted" server.

I am trying to test it out with the following api

http://example.com/api/categories

but get the following error.
FILE: /var/www/forums/library/core/class.request.php
131: trigger_error("Call to unknown method 'Gdn_Request->{$Method}'", E_USER_ERROR);

What could the issue be ?

A "Hello World" example would be helpful

I'm planning on using this to integrate VF with my Drupal site. I've got the application in stalled and enabled (I think). A very simple "hello world" example of how to use the API would be a big help.

Thanks.

-Mike

Bonked when uploaded to server

Hello. Much thanks again Kasper for the time you took out to develop this application.
I keep getting bonked (blank browser window) whenever I upload the application files onto my server. I am using the Vanilla Master(2.2) downloaded from https://github.com/vanilla/vanilla. I also changed the folder name to 'api' on my server. Please help

Failure to Enable in Vanilla 2.2.16.6

Trying to enable 0.2.0 in Vanilla 2.2.16.6 (upgraded from 2.1) and when I hit the "Enable" button in /settings/applications/all, it fails to enable (ie, the "Enable" button still shows instead of "Disable").

No relevant error message in the PHP log.

Depends on PHP 5.4?

Hi, I noticed that the settings/about.php file contains shorthand array syntax which was only introduced in PHP 5.4.

As Vanilla 2.1 supports 5.2 and 2.2 supports 5.3, then shouldn't this plugin also support those versions of PHP?

Installing API on Vanilla 2.1

Hi,
The client has Vanilla 2.1, They don't want to upgrade to 2.2 yet.
I tried enabling the API Application, but I get an error "Success"
I think it should be just disabling some output.

screen shot 2015-08-30 at 11 55 26 am

User->add returns empty response (vanilla 2.2.x)

Hi,

when adding a user the forum/your API returns an empty array - in your endpoint wiki you state, that user,activities, roles arrays are returned. Without any info on the created user (id etc.) it is not possible to go on with some postProcessing in own controllers/applications.

Is this a bug in your API or a misbehaviour in the vanilla core ?

Can't enable application

This looks like exactly what I'm after but I can't seem to get the application enabled. I get a big ugly message that says:

Parse error: syntax error, unexpected ':' in mysite/public_html/simple/applications/api/settings/class.hooks.php on line 35

Pagination of discussions?

it will be good if it can do pagination of discussions or comments. if we have lots of discussion, the load will be pretty heavy?

Domain Subfolder Endpoint Issue

If your vanilla forum is installed in a sub directory ie: domain.com/forum/ the api target does not match the sub folder. The endpoint points to domain.com/api/ instead of pointing to domain.com/forum/api/. The problem lies in the call Gdn::request()->domain() which does not seem to account for sub folder detection.

To fix this every call to Gdn::request()->domain() within the api needs to be replaced with Gdn::request()->domain() ."/". Gdn::request()->WebRoot();

White screen upon installing API with brand new Vanilla 2.2

I've installed this application on a brand new Vanilla 2.2 install and when I attempt to enable it in the Vanilla dashboard I get a white screen. When I enable debug in Vanilla I get the following error in the browser:

Parse error: syntax error, unexpected '[' in D:\wamp\www\vanillaforums\applications\api\settings\bootstrap.php on line 6

screenshot

Example code?

Hi, I am so happy that you built this API, it is going to be really helpful. If we turn out to use it, I make sure my company donates some money to you. That left aside, for now I'm kinda lost. Therefore a couple questions:

  1. I'm trying to find the API url, but localhost/api, 127.0.0.1/api, and 127.0.0.1/~kramer65/vanilla/api all give me a 404. Any ideas what it could be?
  2. Can it be used like a public API, or do I always need to authenticate?
  3. Most importantly; is there some example code anywhere? A simple php file which connects and gets some messages or something?

All tips are welcome!

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 24 bytes)

Hi, i have a problem when i try to create a new category. (POST /categories)

When I do the CURL call to my localhost, i get this:

Fatal error: Allowed memory size of 268435456 bytes exhausted (tried to allocate 24 bytes) in D:\Guillermo\GIT\xxxxxxxxx\library\core\class.dispatcher.php on line 608

xxxxxx is the name of the proyect

any ideas? , i try increasing the memory limit, but no matter how much i set, all is used...

I dont have any problem with GET calls

UrlCode accepts invalid characters

When creating a category, the field "UrlCode" returns error with some characters, like quotes and slashes, but accepts other invalid characters, like #

404 on latest Vanilla

Just did a fresh install on latest Vanilla / master branch. The api endpoints give 404 errors, the admin side looks fine though. Api installed in applications/api.

Having issues in calling Apis that require Auth

I am having issues while calling any of the APIs that require Auth.
For example, I call categories with method PUT to edit that category,I passed username,email,token(Vanilla settings page Seceret label),name,urlcode

{domain}/api/categories/3?name={name}&urlcode={urlcode}&username={username}&email={email}&token={token}

Category with id 3 didnt got update.

What might be wrong in calling API?

Thanks.

I am using Vanilla 2.2.x in localhost.

Email Format on Registering User

Thanks for Support earlier.

When I Call "Add User" API, Mail Has been sent to registered user. But The mail contains Username which I use for authentication.For example Authentication is using xyz user and The user I create is abc..Then If I call api to create user named abc with authentication of xyz...Mail received is : xyz has created your account abc.Your user login details are etcetc.

Broken endpoints

I'm implementing a Ruby gem that wraps the API provided by this project for integrating vanilla with our Ruby-on-Rails web site. Unfortunately, there are a lot of endpoints that do not give the expected behavior. All GET endpoints are fine, however most POST/PUT/DELETE endpoints are broken. This is very frustrating for us as we couldn't find any other API for vanilla integration. Here are what I get:

  • Users:
    • PUT /users/id: Has no effect.
    • POST /users: There is no documentation whatsoever as to how to specify a role in the json body, so I don't know how to format the request for user creation.
    • DELETE /users/id: I get {"Code":405,"Exception":"API.Error.MethodNotAllowed"}
  • Conversations:
    • POST /conversations/id/messages: Has no effect.
  • Roles:
    • PUT /roles/id: Creates a new role with the supplied parameters, rather than updating the one IDed.
    • DELETE /roles/id: Has no effect.
    • POST /roles: There is no documentation for the possible values of the "Permission" field in the json body.
  • Categories:
    • PUT /categories/id: Creates a new category with the supplied parameters, rather than updating the one IDed.
    • DELETE /categories/id: Has no effect.
  • Discussions:
    • POST /discussions/id/comments: I get the following PHP error: PHP Fatal error: Call to a member function FirstRow() on string in /var/www/vanilla/applications/vanilla/controllers/class.postcontroller.php on line 745
    • PUT /discussions/id: Creates a new discussion with the supplied parameters, rather than updating the one IDed.

The most crucial thing that we need to be able to do through the API is to programatically create new users and post comments. I'm not experienced with PHP, but I'm willing to dive into the code base of either the API app or the vanilla app, so any help, insights, hints as to how to fix these issues would be greatly appreciated, let alone fixes!

404 not found on fresh installation

Today I updated Vanilla to the most recent master release, installed the current master branch api and it throws a 404 on every request to {{vanilla}}/api.

Maybe something's changed in the Vanilla router?

User-add : set PhotoURL property

Hi,

is it possible to set the photourl property when adding a user ? in the Profile Object in the response of "find a user" the PhotoUrl/Photo prop is returned - but where can it be set ?

blank website

Website become blank when i extract this plugin to /applications,
do you know how to fix that?

thankyou.

ps: i already rename file to "api" but it was not work

More indepth documentation for your API avail somewhere (especially search call)?

Hi Kasper,

EXCELLENT stuff you've done...
I would like to integrate vanilla to my website using your api and have user synced via calls to create and delete users acccordingly...

But it was troublesome to collect all sorts of infos from all around the web to get it running...

Is there any indepth documentation about your API avail? like how to specify the search string in the search call e.g.

Kudos and all the best
Thomas

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.