This function may be used to import users from your system into CreateProxy. So later you may generate credentials for your specific customers.
You may also pass external_id - this maybe your ID of customer in your external system or database.
Name | Requirements | Options | |
---|---|---|---|
api_key | string|required | Get your api key from https://createproxy.com/dashboard/api | |
name | string | Your customer name | |
external_user_id | string | Your external database user ID | |
status | numeric|required | 1 = active, 0 = inactive | |
proxy_username | string | Proxy username for this user, if empty CreateProxy will generate one, this is used only for Auth by Login | |
proxy_password | string | Proxy password for this user, if empty CreateProxy will generate one, this is used only for Auth by Login | |
whitelist | string | Insert allowed IP Addresses divided by comma - this is used only for Auth by IP login method |
// Read more at https://www.createproxy.com/api/router/add_user/
// createproxy.class.php is available on GitHub: https://github.com/Coxii/CreateProxy
require_once "createproxy.class.php";
$client = new CreateProxyClient('REPLACE_WITH_YOUR_API_KEY');
$params = array();
$params['name'] = "John Doe"; // Your customer name
$params['external_user_id'] = ""; // Your external database user ID
$params['status'] = "1"; // 1 = active, 0 = inactive
$params['proxy_username'] = "ProxyUsername"; // Proxy username for this user, if empty CreateProxy will generate one, this is used only for Auth by Login
$params['proxy_password'] = "ProxyPassword123"; // Proxy password for this user, if empty CreateProxy will generate one, this is used only for Auth by Login
$params['whitelist'] = "111.222.333,444.555.666,777.888.999"; // Insert allowed IP Addresses divided by comma - this is used only for Auth by IP login method
try {
$request = $client->request('router','add_user',$params);
} catch(CreateProxyException $e) {
print_r($e->getMessage());
exit;
}
echo '<pre>';
print_r($request);
echo '</pre>';
// CreateProxy API end
<!-- Read more at https://www.createproxy.com/api/router/add_user/ -->
$api_url = "https://www.createproxy.com/api/request/router/add_user/";
$params = array();
$params['api_key'] = "REPLACE_WITH_YOUR_API_KEY"; // Get your api key from https://createproxy.com/dashboard/api
$params['name'] = "John Doe"; // Your customer name
$params['external_user_id'] = ""; // Your external database user ID
$params['status'] = "1"; // 1 = active, 0 = inactive
$params['proxy_username'] = "ProxyUsername"; // Proxy username for this user, if empty CreateProxy will generate one, this is used only for Auth by Login
$params['proxy_password'] = "ProxyPassword123"; // Proxy password for this user, if empty CreateProxy will generate one, this is used only for Auth by Login
$params['whitelist'] = "111.222.333,444.555.666,777.888.999"; // Insert allowed IP Addresses divided by comma - this is used only for Auth by IP login method
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "$api_url");
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
curl_setopt($ch, CURLOPT_REFERER, $_SERVER['SERVER_NAME']);
curl_setopt($ch, CURLOPT_AUTOREFERER, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch,CURLOPT_ENCODING,"gzip,deflate");
$result=curl_exec($ch);
curl_close($ch);
if($result === false) {
die("Failed to perform request");
}
$response = json_decode($result, true);
if(!$response) {
die('CreateProxy responded with invalid response');
} else if(!isset($response['type'])) {
die('CreateProxy responded with incorrect status key');
} else if($response['type'] == 'error') {
if(isset($response['title']) AND isset($response['message'])) {
die($response['title']. ': ' . $response['message']);
} else if(isset($response['message'])){
die('API ERROR: ' . $response['message']);
} else {
die('API UNDEFINNED ERROR');
}
}
echo '<pre>';
print_r($response);
echo '</pre>';
<!-- CreateProxy API end -->
// read more at https://www.createproxy.com/api/router/add_user/
using System;
using System.Diagnostics;
using System.Net;
using System.IO;
class Program
{
static void Main(string[] args)
{
string api_key = "REPLACE_WITH_YOUR_API_KEY";
string name = "John Doe";
string external_user_id = "";
string status = "1";
string proxy_username = "ProxyUsername";
string proxy_password = "ProxyPassword123";
string whitelist = "111.222.333,444.555.666,777.888.999";
string serviceUri = "https://www.createproxy.com/api/request/router/add_user/";
string post_data = "api_key=" + api_key + "name=" + name + "external_user_id=" + external_user_id + "status=" + status + "proxy_username=" + proxy_username + "proxy_password=" + proxy_password + "whitelist=" + whitelist;
// create a request
HttpWebRequest request = (HttpWebRequest)
WebRequest.Create(serviceUri);
request.Method = "POST";
// turn our request string into a byte stream
byte[] postBytes = System.Text.Encoding.ASCII.GetBytes(post_data);
// this is important - make sure you specify type this way
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postBytes.Length;
Stream requestStream = request.GetRequestStream();
// now send it
requestStream.Write(postBytes, 0, postBytes.Length);
requestStream.Close();
// grab te response and print it out to the console
HttpWebResponse response = (HttpWebResponse)request.GetResponse();
Console.WriteLine(new StreamReader(response.GetResponseStream()).ReadToEnd());
Console.ReadLine();
}
}
curl -X POST -F 'api_key=REPLACE_WITH_YOUR_API_KEY' -F 'name=John Doe' -F 'external_user_id=' -F 'status=1' -F 'proxy_username=ProxyUsername' -F 'proxy_password=ProxyPassword123' -F 'whitelist=111.222.333,444.555.666,777.888.999' https://www.createproxy.com/api/request/router/add_user/
import requests
files = {
'api_key': (None, 'REPLACE_WITH_YOUR_API_KEY'),
'name': (None, 'John Doe'),
'external_user_id': (None, ''),
'status': (None, '1'),
'proxy_username': (None, 'ProxyUsername'),
'proxy_password': (None, 'ProxyPassword123'),
'whitelist': (None, '111.222.333,444.555.666,777.888.999'),
}
response = requests.post('https://www.createproxy.com/api/request/router/add_user/', files=files)