Jump to content

Правильное создание юзера через REST API. Что за параметр?

Featured Replies

Posted
comment_132639

Здравствуйте. Сижу уже почти час, не могу никак реализовать регистрацию через REST API. Отправляю следующий запрос:

<?php
	
	$communityUrl = 'https://forum.demure-rp.ru/';
	$apiKey = '082e2b893312d7c07e295bbadc55eb4c';
		
	$curl = curl_init( $communityUrl . 'api/index.php?core/members?name=Test1&[email protected]&password=123123qwe&group=3' );
	curl_setopt_array( $curl, array(
    		CURLOPT_RETURNTRANSFER	=> TRUE,
    		CURLOPT_POST            => TRUE,
    		CURLOPT_HTTPAUTH	    => CURLAUTH_BASIC,
    		CURLOPT_USERPWD		    => "{$apiKey}:"
	    ) 
	);
	$response = curl_exec( $curl );

	echo $response;

Как видим в качестве параметра я отправляю: name, email, password и group, НО! В документации еще есть 5 параметр:  customFields (type - object, desc - Array of custom fields as fieldId => fieldValue), и я никак не могу понять, как правильно отправлять с ПЯТЫМ параметром customFields, ибо без него, игрок не отображается в "списках пользователей", т.к. у него отображаемое имя - ПУСТОЕ.

  • 3 месяца спустя...
comment_138808

Sorry for replying in English - perhaps you can Google Translate (I don't have RU keyboard with me at the moment).

It is most confusing description of the API, I spent many hours today trying to work out how to use it. It's impossible to decipher from API documentation.

Follow these steps:

1. Go to your Database and find "core_pfields_content" table. Note the field_X. - X will be the "magic number" for your custom field.

2. Load up Postman or Hurl.IT.

3. Change to POST, enter normal parameters.

4. For the last Parameter, enter customFields[X] where X is the number of the field from Step #1. It should look like this (see attachment).

In my example the X is 2. And the value of the custom field is "General". Registered just to post this, hopefully it will help someone.

Good luck

Remember this about POST.PNG

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.


Guest
Ответить в этой теме...

Последние посетители 0

  • No registered users viewing this page.