-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathcreate_subuser.php
More file actions
37 lines (28 loc) · 883 Bytes
/
create_subuser.php
File metadata and controls
37 lines (28 loc) · 883 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
<?php
// Information obtained from authentication
$userId = "";
$token = "";
$url = 'https://api.decodo.com/v1/users/' . $userId . '/sub-users';
$data = array(
"username" => "",
"password" => "",
"traffic_limit" => 0, // Can be float
"service_type" => "" // Possible values: residential_proxies, shared_proxies
);
$payload = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
$headers = array();
$headers[] = "Accept: application/json";
$headers[] = "Content-Type: application/json";
$headers[] = "Authorization: Token $token";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo "Error: " . curl_error($ch);
}
curl_close($ch);
echo $result;