<?php
use Deskpro\API\DeskproClient;
use Deskpro\API\Exception\APIException;
include(__DIR__ . '/vendor/autoload.php');
$client = new DeskproClient('http://deskpro.company.com');
$client->setAuthKey(1, 'dev-admin-code');
if ($_SERVER['REQUEST_METHOD'] === 'POST') {
$body = [
"title" => $_POST["title"],
"content" => $_POST["content"]
];
$resp = $client->post('/articles', $body);
$data = $resp->getData();
echo "Article with ID {$data['id']} has been accepted.";
die();
}
?>
<form action="form.php" method="POST">
Title: <input type="text" name="title"><br>
<textarea
name="content"
placeholder="Article Content"
cols="80"
rows="10"
></textarea><br>
<button type="submit">Submit</button>
</form> copy
Submitting the form should show you something like:
Article with ID 107 has been accepted. copy
Please log in or register to submit a comment.