XenAPI - XenForo PHP REST API

XenAPI - XenForo PHP REST API 1.4.2

No permission to download
I've noticed that the getUser returns a JSON object that does not have the user's email nor does it have the user's location.

The user's location is not a big deal, however, I am not sure why the user's email is not available in the object. Any ideas why? I'm not sure what the reasoning behind this is but one user (me) does have the email.
A very late reply, but I've fixed this in the next version; https://github.com/Contex/XenAPI/commit/46062d0e9a3a5293cba7ca2315193eb4746ec758
 
Hey Contex!

I have replaced $restAPI = new RestAPI('JS9wLg7thi9H1WZaO3Vyhg30Hnt145XS'); that line like so, and the one below it. It keeps throwing error 17 at me. Any reason why? What am I doing wrong?
 
Hey Contex!

I have replaced $restAPI = new RestAPI('JS9wLg7thi9H1WZaO3Vyhg30Hnt145XS'); that line like so, and the one below it. It keeps throwing error 17 at me. Any reason why? What am I doing wrong?

You should not change the one below that line, the code states:
Code:
# DO NOT CHANGE ANYTHING BELOW THIS LINE UNLESS
# YOU REALLY KNOW WHAT ARE YOU DOING

So change that last line back to:
Code:
if ($restAPI->getAPIKey() != NULL && $restAPI->getAPIKey() == 'REPLACE_THIS_WITH_AN_API_KEY') {

I'll see if I can get a static variable string set for that if statement so people don't get confused..
 
You should not change the one below that line, the code states:
Code:
# DO NOT CHANGE ANYTHING BELOW THIS LINE UNLESS
# YOU REALLY KNOW WHAT ARE YOU DOING

So change that last line back to:
Code:
if ($restAPI->getAPIKey() != NULL && $restAPI->getAPIKey() == 'REPLACE_THIS_WITH_AN_API_KEY') {

I'll see if I can get a static variable string set for that if statement so people don't get confused..
Yeah I figured that would be the problem so I tried both ways, leaving it the way it was and changing it. Still error 17,

Regardless I just hacked and slashed away at the base xenForo template php files and worked my way on top of that. Ended up building a nice registration module in Drupal!

Cheers man
 
Hm, I've only added searching for users via the getUsers method.
I'll add a search method if you submit a ticket on GitHub, I'll be doing some coding this/next week.

A thread (title) search would be awesome, to see if a thread with the same title already exists!
 
Can I retrieve search results with this API, @Contex ?
A thread (title) search would be awesome, to see if a thread with the same title already exists!

I've added this to the dev branch for XenAPI 1.4.1

See commits #2b0f2754230725abf8eb4eda2dbdcccf0bfd10cf and #fdd1782d165a729606377efe9ae9b10aea827011

I'll get them merged into master and push the new 1.4.1 version once I finish up a couple of other features.

Example usage:
Code:
api.php?hash=<HASH>&action=search&value=test
api.php?hash=<HASH>&action=search&value=test&type=post

Example response:
Code:
[
  {
    "type": "post",
    "data": {
      "post_id": 9,
      "thread_id": 6,
      "user_id": 1,
      "username": "Contex",
      "post_date": 1404155041,
      "message": "test 2\n\n[I]test\n[\/I]\n[B]nope\n\n[SIZE=6]bbcodetesting[\/SIZE][\/B]",
      "ip_id": 26,
      "message_state": "visible",
      "attach_count": 0,
      "position": 1,
      "likes": 0,
      "like_users": "a:0:{}",
      "warning_id": 0,
      "warning_message": "",
      "last_edit_date": 0,
      "last_edit_user_id": 0,
      "edit_count": 0,
      "absolute_url": "http:\/\/xenapi.net\/index.php?posts\/9\/"
    }
  },
  {
    "type": "thread",
    "data": {
      "thread_id": 6,
      "node_id": 2,
      "title": "test",
      "reply_count": 1,
      "view_count": 0,
      "user_id": 1,
      "username": "Contex",
      "post_date": 1404155016,
      "sticky": 0,
      "discussion_state": "visible",
      "discussion_open": 1,
      "discussion_type": "",
      "first_post_id": 8,
      "first_post_likes": 0,
      "last_post_date": 1404155041,
      "last_post_id": 9,
      "last_post_user_id": 1,
      "last_post_username": "Contex",
      "prefix_id": 0,
      "absolute_url": "http:\/\/xenapi.net\/index.php?threads\/6\/"
    }
  },
  {
    "type": "thread",
    "data": {
      "thread_id": 4,
      "node_id": 2,
      "title": "test",
      "reply_count": 1,
      "view_count": 2,
      "user_id": 1,
      "username": "Contex",
      "post_date": 1401731277,
      "sticky": 0,
      "discussion_state": "visible",
      "discussion_open": 1,
      "discussion_type": "",
      "first_post_id": 5,
      "first_post_likes": 0,
      "last_post_date": 1401731410,
      "last_post_id": 6,
      "last_post_user_id": 1,
      "last_post_username": "Contex",
      "prefix_id": 0,
      "absolute_url": "http:\/\/xenapi.net\/index.php?threads\/4\/"
    }
  }
]

Edit: @r1pe: I've added a "type" called "thread_title" which will only search among thread titles.
 
Last edited:
When using the API to get the resources from a category, I want to return the resources from the parent category and any child categories as well. The basic resource addon does this when displaying resources inside xenforo. Would it be possible to add that to the next version?

a check whether the categoryId being referenced has any children and if so iterate through those as well before returning the array of resources

thanks
 
Can maybe someone post an example on how to create a thread using the API?!

Thanks, best regards,

Edit: This seems to work:

Code:
api.php?action=createThread&node_id=FORUM_NODE_ID&title=THREADTITLE&message=YOUR_POST&grab_as=USERNAME&hash=YOUR_API_KEY

Tobi
 
Last edited:
Top Bottom