Posting to /users/{id}/ reports success=true, but no fields seem to change.
I'm a vBulletin 3.x op that just licensed Xenforo and am looking forward to migrating. However, we need to create some custom scripts as we handle our own user creation, and more... So this morning I'm trying to get the APIs to work for me. It seems I can read data fine (users, threads, etc.). However, when I try to Post, it reports back success=true, but no fields change.
Please help. I'm sure I'm missing something really simple...
Key: Super user, All Scopes, Active.
GET users/4/:
{
"user": {
...
"custom_title": "",
...
"timezone": "America/Los_Angeles",
...
"user_id": 4,
...
"website": ""
}
}1
POST users/4/ (trying to update custom_title, timezone, and website fields):
{
"success": true,
"user": {
...
"custom_title": "",
...
"timezone": "America/Los_Angeles",
...
"user_id": 4,
...
"website": ""
}
}
CODE (tried with and without api_bypass_permissions even though it shouldn't apparently be needed). :
<?php
$edituser = 1;
$showuser = 0;
$APIKEY='_<mykey>';
$urlbase = 'https://<mydomainname>/api/';
$headers = array(
'Content-type: application/json; charset=utf-8',
'XF-Api-User: 1',
"XF-Api-Key: $APIKEY"
);
if ($edituser == 1) {
# Thanks https://xenforo.com/community/threads/api-post-thread-with-curl.163601/
$post = [
'timezone' => 'America/New_York',
'custom_title' => 'BigHope',
'website' =>'BigTrouble'
];
$post = http_build_query($post);
$url = $urlbase . 'users/4/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
echo $json;
}
elseif ($showuser == 1) {
$url = $urlbase . 'users/4/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
$json = curl_exec($ch);
echo $json;
}
?>
I'm a vBulletin 3.x op that just licensed Xenforo and am looking forward to migrating. However, we need to create some custom scripts as we handle our own user creation, and more... So this morning I'm trying to get the APIs to work for me. It seems I can read data fine (users, threads, etc.). However, when I try to Post, it reports back success=true, but no fields change.
Please help. I'm sure I'm missing something really simple...
Key: Super user, All Scopes, Active.
GET users/4/:
{
"user": {
...
"custom_title": "",
...
"timezone": "America/Los_Angeles",
...
"user_id": 4,
...
"website": ""
}
}1
POST users/4/ (trying to update custom_title, timezone, and website fields):
{
"success": true,
"user": {
...
"custom_title": "",
...
"timezone": "America/Los_Angeles",
...
"user_id": 4,
...
"website": ""
}
}
CODE (tried with and without api_bypass_permissions even though it shouldn't apparently be needed). :
<?php
$edituser = 1;
$showuser = 0;
$APIKEY='_<mykey>';
$urlbase = 'https://<mydomainname>/api/';
$headers = array(
'Content-type: application/json; charset=utf-8',
'XF-Api-User: 1',
"XF-Api-Key: $APIKEY"
);
if ($edituser == 1) {
# Thanks https://xenforo.com/community/threads/api-post-thread-with-curl.163601/
$post = [
'timezone' => 'America/New_York',
'custom_title' => 'BigHope',
'website' =>'BigTrouble'
];
$post = http_build_query($post);
$url = $urlbase . 'users/4/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$json = curl_exec($ch);
echo $json;
}
elseif ($showuser == 1) {
$url = $urlbase . 'users/4/';
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_URL, $url);
$json = curl_exec($ch);
echo $json;
}
?>