Itβs useful to use the built-in and full-featured API engine to perform any kind of integrations. In this article, I will show you step-by-step API call examples to create a new user account on the system.
The benefit of using API call instead of the standard user sign-up form is, API call gives you flexibility on setting target user group and reputation level.
First, you need to execute Admin.Login
API call to create an admin session:
curl -X POST \
http://yourdomain.com/oempro/api.php \
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-F command=Admin.Login \
-F username=admin_username \
-F 'password=admin_password' \
-F disablecaptcha=1 \
-F responseformat=JSON
If your admin username and password credentials are correct, you will get a session ID as a response:
{
"Success": true,
"ErrorCode": 0,
"SessionID": "xxxxxxxx",
"AdminInfo": {
"AdminID": "1",
"Name": "Administrator Name",
"EmailAddress": "[email protected]",
"Username": "admin_username",
"Password": "admin_password"
}
}
Now you have your admin session ID. Itβs time to create our new user account:
curl -X POST \
http://yourdomain.com/oempro/api.php \
-H 'Accept: */*' \
-H 'Accept-Encoding: gzip, deflate' \
-H 'Cache-Control: no-cache' \
-H 'Connection: keep-alive' \
-H 'Content-Type: application/x-www-form-urlencoded' \
-H 'Host: yourdomain.com' \
-H 'cache-control: no-cache' \
-F command=User.Create \
-F sessionid=xxxxxxxxxxx \
-F responseformat=JSON \
-F relusergroupid=1 \
-F [email protected] \
-F username=test1octeth \
-F password=test1pass \
-F 'firstname=Test 1 User' \
-F 'lastname=Test 1 Last Name' \
-F timezone=Europe/London \
-F language=en \
-F reputationlevel=Untrusted \
-F accountstatus=Enabled \
-F availablecredits=100
If the user create process is completed successfully, you will get a similar response:
{
"Success": true,
"ErrorCode": 0,
"UserID": 6
}
- The article was helpful
- The article was not helpful
0 voters