XenAPI - XenForo PHP REST API

XenAPI - XenForo PHP REST API 1.4.2

No permission to download
Hello, rated performance and loading time of pages it gives what please? :)
 
Hello, I have a website (use Symfony2 frameworks), how use the Xenforo API for get a basic query please ? :)

Example:

Xenforo index:
C:/wamp/www/xenforo/*

WebSite index:
C:/wamp/www/Symfony2/web/*

In my code (in oriented Object), how access and use the xenforo api please ?
 
Hello, I have a website (use Symfony2 frameworks), how use the Xenforo API for get a basic query please ? :)

Example:

Xenforo index:
C:/wamp/www/xenforo/*

WebSite index:
C:/wamp/www/Symfony2/web/*

In my code (in oriented Object), how access and use the xenforo api please ?
See http://xenforo.com/community/threads/xenapi-xenforo-rest-api.34270/#post-399071 for examples.
I'm working on the documentation as well: https://github.com/Contex/XenAPI/wiki/Actions

Other than that it's pretty straight forward, you send a request to the api.php, which returns a JSON object.
If you're using PHP, you'll have to use the json_decode function to create a variable with all the JSON data.

Hope that helps you enough to get started.
 
api.php?... with include ?

PHP:
include('api.php?action=getAlerts&value=USERNAME&type=fetchAll&hash=USERNAME:HASH') ?

How to communicate with api.php please ?
I include the file and instantiates the class?
 
api.php?... with include ?
No, this is a REST API, which means that it only responses to HTTP requests.
I can look into allowing the functions to be used locally, but I can't promise anything as I only intended to make a REST API.

You can however send a request with cURL or the file_get_contents function.
 
Have you a simple example for an basic query please ?


Example:
PHP:
<?php
$contents = file_get_contents("http://www.example.com/api.php");
$json = json_decode($contents);
var_dump($json);
?>

Request response:
Code:
{
  "error": 3,
  "message": "Missing argument: 'action'"
}

JSON object:
Code:
object(stdClass)#1 (2) { ["error"]=> int(3) ["message"]=> string(26) "Missing argument: 'action'" }

I would however recommend using cURL instead, there are tons of examples on the internet if you search for them.
 
Could this be used to create a Xenforo Single Sign On ?
Similar to this ...
http://vbsso.com/

Supported Platforms
WordPress 3.0/3.1/3.2/3.3/3.4/3.5
WordPress Multisite 3.0/3.1/3.2/3.3/3.4
Drupal 6.x, 7.x
Mediawiki 1.19.x, 1.20.x
 
I haven't worked that much on it but I'll make sure to have it well documented when finished.

Either way, here are some simple uses:

Authentication
Code:
api.php?action=authenticate&username=Contex&password=pass

This would return this error if wrong:
Code:
{"error":5,"message":"Authentication error: Invalid username or password!"}

And if successful, it returns a hash:
Code:
{"hash":"x"}
Where x is the returned hash, you have to use this hash on every other action.

Examples of actions

Grabbing user information
The value parameter is the search string, e-mails, usernames and user id's work.
Code:
api.php?action=getUser&value=Contex&hash=x
Would return a JSON object of the user information.

Code:
{"user_id":1,"username":"Contex","email":"me@contex.me","gender":"","custom_title":"","language_id":1,"timezone":"Europe\/Amsterdam","visible":1,"user_group_id":3,"secondary_group_ids":"2,7","message_count":159,"conversations_unread":0,"register_date":1333977020,"last_activity":1345149999,"trophy_points":28,"alerts_unread":0,"avatar_date":1342625592,"avatar_width":192,"avatar_height":192,"gravatar":"","user_state":"valid","is_moderator":1,"is_admin":1,"is_banned":0,"like_count":32,"warning_points":0,"friend_count":0,"personal_friend_count":0,"mood_id":20}

Grabbing user avatar
Code:
api.php?action=getAvatar&value=Contex&hash=x
Returns the link to the user's avatar, if they have Gravatar enabled it would link that instead.
The value parameter is the search string, e-mails, usernames and user id's work.

Code:
{"avatar":"http:\/\/www.x.com\/data\/avatars\/m\/0\/1.jpg?1342625592"}

Searching for users
The value parameter is the search string, usernames and wildcards (use * as a wildcard) work.
Code:
api.php?action=getusers&value=Cont*&hash=x
Return a list of matched usernames.

Code:
[{"username":"Contex"},{"username":"ContexTest"},{"username":"ContexTesting"}]

Grabbing group information
The value parameter is the search string, group id's and group names are both accepted.

Code:
api.php?action=getgroup&value=Guest&hash=x
Return the group information.

Code:
{"user_group_id":1,"title":"Unregistered \/ Unconfirmed","display_style_priority":0,"username_css":"","user_title":"Guest"}

I haven't gotten around to add more content to it, but I've made the source open to everyone if they wish to contribute, I'll get around to it eventually.

Helpful Add-on ! Hope you provide us a complete white page soon !
 
Could this be used to create a Xenforo Single Sign On ?
Similar to this ...
http://vbsso.com/

Supported Platforms
WordPress 3.0/3.1/3.2/3.3/3.4/3.5
WordPress Multisite 3.0/3.1/3.2/3.3/3.4
Drupal 6.x, 7.x
Mediawiki 1.19.x, 1.20.x
Odd, didn't get an alert for this.

I'm not sure, I'll have to take a look.

Helpful Add-on ! Hope you provide us a complete white page soon !
I was working on something here, although it's not finished yet: https://github.com/Contex/XenAPI/wiki/Actions

Feel free to review the addon on the resource manager and comment on what you want me to add :)
 
OMG! this looks so good.
Question before I actually and try it out.

Can I use this to grab 10 members with most post ?
for example: api.php?action=getusers&orderby=postcount&direction=DESC
?

I might be able to contribute in the development, but before I would need to see how its actually working.

Is there any docs that says, what actions are available and arguments each action can take and values will it return ?

Thanks
 
OMG! this looks so good.
Question before I actually and try it out.

Can I use this to grab 10 members with most post ?
for example: api.php?action=getusers&orderby=postcount&direction=DESC
?

I might be able to contribute in the development, but before I would need to see how its actually working.

Is there any docs that says, what actions are available and arguments each action can take and values will it return ?

Thanks
I can try to get the "orderby" and "order" added to the API for the next release, "getUsers" is just for search through usernames, I'll see if I can get things changed for the next release.


The code is open source, I created a REST API which uses my XenAPI class.
The REST API code can be found here: https://github.com/Contex/XenAPI/blob/master/net/xenapi/XenAPI/api.php#L54
The XenAPI code can be found here: https://github.com/Contex/XenAPI/blob/master/net/xenapi/XenAPI/api.php#L861

There is a documentation in the works, I just haven't had time to document all the actions.
Here's the current action list: https://github.com/Contex/XenAPI/wiki/REST-API-Actions#wiki-actions
However, the code is fully documented, so if you wish to look at what an action does, you can check the code.
Here's the documentation for "getGroup" as an example: https://github.com/Contex/XenAPI/blob/master/net/xenapi/XenAPI/api.php#L605
 
Hey contex, I just updated the api with the latest release. By simply replacing the api.php file in the root directory but now I am getting the following error

Code:
{"error":17,"message":"The API key has not been changed, make sure you use another API key before using this API."}

Hope you can help.
 
Hey contex, I just updated the api with the latest release. By simply replacing the api.php file in the root directory but now I am getting the following error

Code:
{"error":17,"message":"The API key has not been changed, make sure you use another API key before using this API."}

Hope you can help.
Take a look at line #4 of the api.php: https://github.com/Contex/XenAPI/blob/master/net/xenapi/XenAPI/api.php#L20
Change this something else, or remove that line.
 
After removing that line I get these errors when I use some of the authenticate urls

Like this url

Code:
/api.php?action=authenticate&username=Shady&password=pass

It gives me this error

Code:
{"error":1,"message":"Argument: \"hash\", is empty\/missing a value"}
Good catch, can't believe I didn't test that, I'll push a new version a couple of minutes with a fix.
 
Top Bottom