Jump to content

Create user API


CrazyCalmMedia

Recommended Posts

Hello All,

I have configure REST API to create user on forum. following is the code. but when i send the request to forum it always return guest user and not save in forum DB

 

Following is the registration API code

 

$communityUrl = $this->live_base_url."forums/";
            $apiKey = 'XXXXXXXXXXXXXXXXXXXXXXXXXX';
            $url =$communityUrl . 'api/core/members/';
            $curl = curl_init($url);
            curl_setopt($curl, CURLOPT_URL,$url);
            curl_setopt($curl, CURLOPT_RETURNTRANSFER,TRUE);
            curl_setopt($curl, CURLOPT_HTTPAUTH,CURLAUTH_BASIC);
            curl_setopt($curl, CURLOPT_USERPWD,$apiKey);
            curl_setopt($curl, CURLOPT_POST, 1);
            curl_setopt($curl, CURLOPT_POSTFIELDS,
               "name=".$userName."&email=".$email."&password=".$password."&group=3");

            $response = curl_exec($curl);
            $json_a = json_decode($response, true);
            //print_r($json_a);exit();
            if(!isset($json_a['errorCode']) && empty($json_a['errorCode'])){

                if(isset($json_a['id']) && !empty($json_a['id'])){
                    // Update record in main database with forum ID.
                }
            }else{
                return false;
            }

 

Response from server

Request Data

{ "name": "testUser", "email": "testuser@test.com", "password": "test123!", "group": "3" }

Response

{ "id": null, "name": "Guest testUser", "title": null, "timeZone": "UTC", "formattedName": "Guest testUser", "primaryGroup": { "id": 3, "name": "Members", "formattedName": "Members" }, "secondaryGroups": [], "email": "testuser@test.com", "joined": "2018-03-06T06:55:51Z", "registrationIpAddress": "192.168.100.3", "warningPoints": 0, "reputationPoints": 0, "photoUrl": "https:\/\/www.domain.com\/forums\/uploads\/set_resources_2\/84c1e40ea0e759e3f1505eb1788ddf3c_default_photo.png", "profileUrl": "https:\/\/www.domainname.com\/forums\/profile\/0-testUser\/", "validating": false, "posts": 0, "lastActivity": "1970-01-01T00:00:00Z", "lastVisit": "1970-01-01T00:00:00Z", "lastPost": "1970-01-01T00:00:00Z", "profileViews": null, "birthday": null, "customFields": [] }

 

 

Please help me to find what i am missing here.

Thanks in advance.
 

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...