Creating (registering) an User in the WebTV
support, ws.webtv, api, users, create
GET vars specific to this request:
Var | Value | Description |
go | users | The API section |
do | create | The API action |
Resulting Request URL:
The resulting request URL would be similar to this (don't forget to append the required info: key, timestamp, salt and signature):
https://....../api.php?go=users&do=create&{required information}
The following POST vars are required.
Case 1 - Standard registration:
Var | Value | Description |
login | (string) Username | [Up to 40 characters] Username (Login)... - Make sure to verify it first |
password | (string) Password | Password... |
(string) E-Mail | [Up to 100 characters] The User E-Mail... - Make sure to verify it first | |
alias | (string) Alias | [Up to 60 characters] A display name (the public User name). |
notify_webmaster | (int) 0|1 | [Not required but recommended] Whether to send a notification message to the WebTV Webmaster. |
Case 2 - Registration using an external auth provider (WS.WebTV 1.8.5+):
Var | Value | Description |
login | (string) Username | [Up to 40 characters] Supply "timestamp@ext.auth" (timestamp is a Unix Timestamp). |
password | (string) Password | Random alphanumeric value... |
(string) E-Mail | [Up to 100 characters] Either provide the E-Mail from external auth provider or supply "timestamp@ext.auth".(timestamp is a Unix Timestamp). | |
alias | (string) Alias | [Up to 60 characters] Screen name from external auth provider. |
notify_webmaster | (int) 0|1 | [Not required but recommended] Whether to send a notification message to the WebTV Webmaster. |
ext_auth | (int) 1 | Indicate that this is a registration using an external auth provider. |
ext_provider | (string) auth_provider | Name of the auth provider. Available options: "twitter", "facebook", "oauth", "google", "openid" |
ext_user_id | (string) external_user_id | ID of the user, from the external auth provider. |
ext_token | (string) external_token | [Optional] If you have a token (for the user) from the external auth provider, provide it here. |
ext_secret | (string) external_sectret | [Optional] If you have a secret (for the user) from the external auth provider, provide it here. |
The following POST vars are optional but require the Advanced User Management extension.
Var | Value | Description |
status | (int) status | Possible values: 0 (inactive), 1 (active), 2 (pending verification). |
send_user_verification_email | (int) 0|1 | [Only if status=2] This will send a verification E-mail to the User. The User will be activated after following the link on the verification E-Mail. |
store_post_registration | (int) 0|1 | [Only if Store extension is active] Whether to allow the Store extension to perform any post registration process; for example, add credit to the User account according to the configuration settings. |
access_level | (int) access level | Possible values: 0 (Webmaster), 1 (Administrator), 2 (Author), 3 (Contributor), 4 (Paid subscriber), 5 (Free Subscriber). |
id_privilege_set | (int) ID privilege set | [Only if access_level was specified] ID of the privilege set. If not specified, the default privilege set for the access level assigned to the User will be used. NOTE: This variable is available since WS.WebTV 2.2 |
cms_access | (int) 0|1 | Whether to allow the User to access the Content Administration interface. |
content_creation_limits | (int) 0|1 | [Only if access_level is 2 (Author) or 3 (Contributor)] Possible values: 0 (global), 1 (specific, per user). |
max_created_clips | (string) limits | [Only if content_creation_limits = 1] 5 comma separated values (one per clip type). Example: '100,100,1,100,100' means 100 Standard Clips, 100 StreamClip VOD, 1 StreamClip Live, 100 EmbedClips and 100 Auto-Encoding Clips. Note: 0 = no limit. |
max_created_channels | (int) limit | [Only if content_creation_limits = 1] Max number of Video Channels. Note: 0 = no limit. |
max_created_news | (int) limit | [Only if content_creation_limits = 1] Max number of News + Events. Note: 0 = no limit. |
max_created_galleries | (int) limit | [Only if content_creation_limits = 1] Max number of Galleries. Note: 0 = no limit. |
max_created_assorted_files | (int) limit | [Only if content_creation_limits = 1] Max number of Assorted Images.
Note: 0 = no limit. NOTE: This variable is available since WS.WebTV 3 |
max_video_upload_size | (int) limit | [Only if content_creation_limits = 1] Size in MB. |
terms_conditions_accepted | (int) 0|1 | Whether the User has accepted the Terms and Conditions. Keep in mind that if the WebTV is configured to request this, and you set this to 0 (not accept) , or omit it, you will receive and error. NOTE: This variable is available since WS.WebTV 3.0.1 |
privacy_policy_accepted | (int) 0|1 | Whether the User has accepted the Privacy Policy.Keep in mind that if the WebTV is configured to request this, and you set this to 0 (not accept) , or omit it, you will receive and error. NOTE: This variable is available since WS.WebTV 3.0.1 |
eml_receive_site_news | (int) 0|1 | Whether the User has given consent for receiving Site News. NOTE: This variable is available since WS.WebTV 3.0.1 |
eml_receive_new_content_digest | (int) 0|1 | Whether the User has given consent for receiving New Content Digest. NOTE: This variable is available since WS.WebTV 3.0.1 |
lang_frontend | (string) lamguage_code | The language choice for the Front-End. Possible values: Empty ('') for default/global language or corresponding language code. If the provided language code does not exist then the default/system language will be used. NOTE: This variable is available since WS.WebTV 52pf3 |
lang_backend | (string) lamguage_code | The language choice for the Back-End. Possible values: Empty ('') for default/global language or corresponding language code. If the provided language code does not exist then the default/system language will be used. NOTE: This variable is available since WS.WebTV 52pf3 |
name | (string) name | The real name (first name) of the User. |
surname | (string) surname | The surname (last name/family name) of the User. |
gender | (int) gender | Possible values: 0 (Unknown), 1 (Male), 2 (Female). |
birthdate_y | (int) year | Birthdate year YYYY. |
birthdate_m | (int) month | Birthdate month (1-12). |
birthdate_d | (int) day | Birthdate day (1-31). |
company | (string) organization | Company or organization. |
vat | (string) VAT | This field is used for storing a fiscal/tax identification number. For example, VAT number in Europe or NIF/CIF/DNI/NIE in Spain. |
address | (string) address | Full address. |
postal_code | (string) postal code | The postal code. |
country | (string) country | Full country name. |
telephone | (string) telephone | The telephone number. |
web | (string) URL | User Website. |
notes | (string) notes | Administrator notes. This field can only be seen by Webmasters and Administrators. |
avatar_display | (int) avatar mode | Possible values: 0 (WebTV Image), 1 (Gravatar, Mistery-Man), 2 (Gravatar, Identicon), 3 (Gravatar, Monsterid), 4 (Gravatar, Wavatar), 5 (Gravatar, Retro). |
reg_referer | (string) referer | The referer URL (if any). For example, if the User registration was originated from another Website. |
reg_ip | (string) IP Address | The IP address of the User. When not provided, the WebTV will use the detected IP (the application IP). |
reg_useragent | (string) user agent | The user agent (normally, the Browser info). |
reg_content_referral | (string) JSON object | The reference to the WebTV content from which the user registered (for example, if the user registered after visiting a specific restricted Channel, Clip). Thus, this data allows identifying if the origin of a registration is the content of the WebTV. The data must be a JSON object and, if provided, it must contain the following properties: - "content_type": Can be "channel", "clip" or "gallery" - "content_id": The ID of the content - "content_title": The title of the content or empty string - "content_url": The content URL or empty string NOTE: This variable is available since WS.WebTV 56pf3 |
social_page_facebook | (string) URL | URL of Facebook profile page |
social_page_googleplus | (string) URL | URL of Google+ profile page |
social_page_twitter | (string) URL | URL of Twitter profile page |
social_page_linkedin | (string) URL | URL of LinkedIn profile page |
social_page_instagram | (string) URL | URL of Instagram profile page NOTE: This variable is available since WS.WebTV 2.4pf2 |
social_page_flickr | (string) URL | URL of Flickr profile page |
social_page_vkontakte | (string) URL | URL of VKontakte profile page |
social_page_tuenti | (string) URL | URL of Tuenti profile page |
social_page_other | (string) URL | URL of other profile page |
profile_page_privacy | (int) privacy | Whether the User profile page is public or private. Possible values: 0 (public), 1 (WebTV Users only), 2 (private). |
profile_page_about | (string) text | Public "About" text of the User |
profile_page_show_country | (int) 0|1 | Whether to display the User country in its public profile or not. |
profile_page_show_web | (int) 0|1 | Whether to display the User Website in its public profile or not. |
profile_page_show_social | (int) 0|1 | Whether to display the User social links in its public profile or not. |
If the request was successful, you'll receive a response containing:
• ok: If the User was created (registered) successfully.
• id: The ID of the User.
• activation_key: The activation key.
Example:
{ "ok": "User was registered successfully", "id": 78, "activation_key": "bj8g3dz5xsntprsy0icc" }
If the request failed (for example, if the Username/Login is invalid), you'll receive a response like the following:
{ "error": "REGISTRATION_ERROR", "error_long": "Invalid login" }
Possible Error Messages
Besides the general errors, this request can return the following errors:
• REGISTRATION_ERROR | {Message}
It was not possible to create (register) the User because of the specified reason.
Preparing GET and POST data.
// The GET vars $GET_VARS = array( "go" => "users", "do" => "create" ); // The POST vars $POST_VARS = array( "login" => "mrbean", "password" => "123", "alias" => "Mr. Bean", "email" => "mrbean@beanmail.bean", "notify_webmaster" => 1, // Send a notification E-Mail to the Webmaster // ----- Optional fields (Advanced User Management extension required) "status" => 2, // Pending verification "send_user_verification_email" => 1, // Send a verification E-mail to the User "store_post_registration" => 1, // Allow the Store Extension to perform post registration process "access_level" => 5, // 5 (Free Subscriber) "cms_access" => 1, // 1 Content Administrator access allowed "name" => "Rowan", // The real name of the User "surname" => "Atkinson ", // The surname/last name of the User "gender" => 1, // 1 (male) "birthdate_y" => 1955, // Birthdate year "birthdate_m" => 1, // Birthdate month "birthdate_d" => 6, // Birthdate day "company" => "", "address" => "", "postal_code" => "", "vat" => "", "country" => England"", "telephone" => "", "web" => "http://www.mrbean.com/", "notes" => "", "avatar_display" => 3, // 3 (Gravatar, Monsterid) "reg_referer" => "external api", "reg_ip" => "xxx.xxx.xxx.xxx", "reg_useragent" => "", "social_page_facebook" => "http://www.facebook.com/MrBean", "social_page_googleplus" => "", "social_page_twitter" => "https://twitter.com/MrBean", "social_page_linkedin" => "", "social_page_flickr" => "", "social_page_vkontakte" => "", "social_page_tuenti" => "", "social_page_other" => "", "profile_page_privacy" => 0, // User profile page is public "profile_page_about" => "Rowan Atkinson’s comic acting genius has created a highly original work for television. The Mr Bean series has been sold to 190 territories worldwide and has won an International Emmy and the Golden Rose of Montreux", "profile_page_show_country" => 1, // Display the User country in its public profile "profile_page_show_web" => 1, // Display the User Website in its public profile "profile_page_show_social" => 1 // Display the User social links in its public profile );
Generating the salt, timestamp, signature and sending the request
*** The following code block is common to all signed requests ***
// Collect the API Base URL and Credential info $API_URL = "https://www.mywebtvdomain.tv/api.php"; $API_KEY_ID = "1b323a1cb879fd4e66530fbad07a32ee"; $API_SHARED_SECRET = "MWIzMjNhMWNiODc5ZmQ0ZTY2NTMwZmJhZDA3YTMyZWViOTQ3MDJiOGM2ZTU2NjE3"; // keep this safe!!! // Generating salt and timestamp $salt = md5(mt_rand()); $timestamp = time(); $signature = base64_encode(hash_hmac('sha256', $salt.$timestamp, $API_SHARED_SECRET, true)); // Generating the validation signature // - Default method: using base64_encode(hash_hmac(...)) $signature = base64_encode(hash_hmac('sha256', $salt.$timestamp, $API_SHARED_SECRET, true)); // comment this line if using the next method // - Simplified method - available since v60: using md5(). // This method requires the variable $API_SIGNATURE_GENERATION_MODE = 1; in the config/Config.inc.php file. // $signature = md5($salt."-".$timestamp."-".$API_SHARED_SECRET); // you must "uncomment" this line when using the simplified method // Append the timestamp, salt, key and signature to the GET vars $GET_VARS["timestamp"] = $timestamp; // UTC timestamp $GET_VARS["salt"] = $salt; $GET_VARS["key"] = $API_KEY_ID ; // The API Key ID: This is public and is used by the API to identify the application; $GET_VARS["signature"] = $signature; // Create the request URL. Please note that if you do not use PHP buit in function // to create the HTTP query then don't forget to URL encode the values $REQUEST_URL = $API_URL."?".http_build_query($GET_VARS); // The previous will build an URL like .../api.php?go=api_subject&do=api_action&etc... // Create a new cURL resource and set the appropriate options $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $REQUEST_URL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_HEADER, false); curl_setopt($ch, CURLOPT_POSTFIELDS, $POST_VARS); // If your PHP host does not have a valid SSL certificate, you will need to turn off SSL // Certificate Verification. This is dangerous (!), and should only be done temporarily // until a valid certificate has been installed curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); // Turns off verification of the SSL certificate. curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); // Turns off verification of the SSL certificate. // Sending the request to the API $response = curl_exec($ch); // Processing the response if (!$response) { echo 'API call failed'; } else { print_r(json_decode($response,true)); }