XF 2.1 REST API

Welcome to another HYS for 2.1 and this one's a biggie. If you haven't seen the previous entries about what's coming in XF 2.1, check them out here.

Although Halloween may be over, why not trick the "Watch forum" link into giving you a treat, by getting it send you an email whenever we post about new things in the pipeline.

As I write this, our most popular suggestion was a REST API and with 2.1, it's here. While this is a fairly developer-focused feature on its own, it opens up many more integration options. This will make it easier to get data into or out of XenForo, without having to understand the underlying PHP framework that XF is built on.

The API breaks down into a few distinct components, so let's look at those in turn.
 
Hi there,

I want to add avatars to users with the api.

What the api expect in the as avatar. If I set avatar to the file with full path it doesn't work.
Code:
$post = array('avatar'=>'/dir/foo/bar/avatar.jpg');

The api response is success.

If I set avatar to anythingelse it will response with success as well.
You're supposed to send a file, not a file path.
 
Once again, support related posts must be made in the relevant forum, not HYS threads or public forums.
 
hello I need help with restAPI and bash. For academic reasons I need to make a new reply on a specific thread with a content of a txt file. The forum isnt mine but the admin will activate api for my user.

few questions:

1 according to https://xenforo.com/community/pages/api-endpoints/ I need to know the thread ID: how can I retrieve it?
2 some issues creating the array from bash, how can I translate something like this php

Code:
$data = array(
    'thread_id' => 7,
    'message' => 'This is sample post'

in bash?

3 how can I know the api link for the forum strarting from its address?

I'm planning to use something like this:

curl -X POST https://mysite.com/api/nodes -H 'XF-API-KEY: mykey' -d 'thread_id=7'
curl -X POST https://mysite.com/api/nodes -H 'XF-API-KEY: mykey' -d @mytxt.txt

could it work? Thank you
 
The license holder will need to add your forum user name to their account so you can post in the support forums.
 
I am searching since a half hour, but I cant find any example code how to fetch threads with the API.


PHP:
            try
            {
                $client = \XF::app()->http()->client();
                $response = $client->request('GET', 'https://localhost/api/threads/',
                    [
                        'debug' => false,
   
                        'headers' =>
                            [
                                'XF-Api-Key' => '123',
                                'XF-Api-User: 2',
                                //'Content-Type' => 'application/json',
                                'Content-Type: application/x-www-form-urlencoded',
                            ],
   
                        'form_params' =>
                            [
                                                      ???
                            ],
                    ]
                );


But where is the result?
I checked $response, but there is no threads/thread
 
If you need support on the API, post in the development forum.

Support is not provided in HYS threads.
 
Top Bottom