sdev
Member
Can't get the API to work.
Does anyone know how one could post a thread with it?
(btw, I've searched the whole API forum by hand. There is no information on how to post a thread, best thread is this one but I cant get Guzzle to work anyway https://xenforo.com/community/threa...d-look-like-using-the-api-with-guzzle.160858/. btw2, the API has real potential for a game changer).
Output
Does anyone know how one could post a thread with it?
(btw, I've searched the whole API forum by hand. There is no information on how to post a thread, best thread is this one but I cant get Guzzle to work anyway https://xenforo.com/community/threa...d-look-like-using-the-api-with-guzzle.160858/. btw2, the API has real potential for a game changer).
Code:
$headers = array(
'Content-type: application/json',
'XF-Api-User: 1',
'XF-Api-Key: xxxxx'
);
$post = [
'node_id' => 6,
'title' => 'test',
'message' => 'TestMessage',
];
$post = json_encode($post);
$url = 'https://www.example.com/api/threads/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POSTFIELDS,$post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
echo $json;
Output
Code:
{ "errors": [ { "code": "required_input_missing", "message": "Required input missing: node_id, title, message", "params": { "missing": [ "node_id", "title", "message" ] } } ] }