1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Unmaintained XenAPI - XenForo PHP REST API 1.4.2

PHP REST API to use on other projects

  1. Contex

    Contex Well-Known Member

    Contex submitted a new resource:

    XenAPI - XenForo REST API (version 1.0) - PHP REST API to use on other projects

    Read more about this resource...
     
  2. Adam Howard

    Adam Howard Well-Known Member

    Thank you for posting this as a free open source resource. And also thank you so very much for developing this. I'm very sure this is something that can be put to some very good use. (y)
     
  3. Contex

    Contex Well-Known Member

    I'm trying to give something back to the community as XenForo is so far the best software I've used by far.
    It's open source for a reason, so that others can contribute if they wish, I will be working on adding more features the upcoming weeks.
    Thank you for the kind comment!
     
  4. Opacity

    Opacity Member

    This is very nice. Thank you for creating this. ;) Can't wait to see what you've come up with in the next update. :)
     
  5. Kintaro

    Kintaro Well-Known Member

    some practical example of use?
     
  6. Contex

    Contex Well-Known Member

    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.
     
  7. David_

    David_ Active Member

    Just wondering is there a way to grab a users post count and active alerts?

    I'd like to build a widget on wordpress that displays just like the user block on xenforo.
     
    faeronsayn and LPH like this.
  8. LPH

    LPH Well-Known Member

    Just bumping up this question because I also would like to get active alerts onto the WordPress side.
     
  9. Contex

    Contex Well-Known Member

    Well, if you want to grab the amount of messages & active alerts, that's possible, (see example above).
    However getting the contents of the active alerts haven't been implemented yet, I could get it added tomorrow if you need it.
     
  10. LPH

    LPH Well-Known Member

    Maybe I'm not understanding the examples above - and didn't see grabbing the alerts. I'll look again.

    I would love to have the contents available too. If you have time then that would be fantastic !
     
  11. Contex

    Contex Well-Known Member

    Out of curiosity, are you using PHP for the Wordpress plugin/add-on? If not, what are you using?

    To crab user post/alert count, use:
    Code:
    api.php?action=getUser&value=Contex&hash=x
    Which returns something like this:
    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}
    Use the "message_count" key for post/message count.
    Use the "alerts_unread" key for unread alerts count.

    It's a JSON object, so if your plugin is in PHP/JS, it shouldn't matter, it's rather easy to navigate through.

    I'll add a method to grab the alert contents sometime this week.
     
    Brandon Sheley likes this.
  12. LPH

    LPH Well-Known Member

    I was modifying the header.php in a child theme for WordPress.
     
  13. Digital Doctor

    Digital Doctor Well-Known Member

    Is the REST API taking a break ? (a "rest" ;) )
     
  14. Contex

    Contex Well-Known Member

    I'm on a vacation in Australia so I haven't had time to do much. Feel free to request features you wish to be added and I will add them as soon as I can.
     
  15. Digital Doctor

    Digital Doctor Well-Known Member

    Must be hot !
     
  16. tmtgr

    tmtgr Member

    Thanks for the great resource :)
    I'm using it to integrate some forum functionality with my minecraft server.
     
    Digital Doctor likes this.
  17. Contex

    Contex Well-Known Member

    Glad to hear you made good use of it :)
     
    Digital Doctor likes this.
  18. Brandon Sheley

    Brandon Sheley Well-Known Member

    This looks great!

    Time to start playing around :D
     
  19. Contex

    Contex Well-Known Member

    Please do, and if you do have any requests, feel free to post them here or even on GitHub.

    I'll be posting an update sometime this week, where I've documented every part of the code and made it easier for developers to add additional code.
     
  20. Contex

    Contex Well-Known Member

Share This Page