-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcreate_users.php
68 lines (64 loc) · 2.64 KB
/
create_users.php
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
<?php
include_once "config.inc.php";
?>
<html>
<head>
<title>Create Users</title>
<meta charset="UTF-8" />
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
</head>
<body>
<nav class="navbar navbar-inverse ">
<div class="container">
<div class="navbar-header">
<button type="button" class="navbar-toggle collapsed" data-toggle="collapse" data-target="#navbar" aria-expanded="false" aria-controls="navbar">
<span class="sr-only">Toggle navigation</span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
<span class="icon-bar"></span>
</button>
<a class="navbar-brand" href="#">Creating users for testing...</a>
</div>
</div>
</nav>
<div class="container">
<?php
$row = 1;
if (($handle = fopen("user_data.csv", "r")) !== FALSE) {
while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
//Get each user data from every row
$uniqueid = $data[0];
$firstname = $data[1];
$lastname = $data[2];
//Get current UTC timestamp in milliseconds
date_default_timezone_set('UTC');
$timestamp = time()*1000;
$access_token = "";
//Post data to setup/initialize user
$data_string = "client_id=".$CLIENT_ID."&client_secret=".$CLIENT_SECRET."&grant_type=".$USER_INITIALIZE_GRANT_TYPE."&uniqueid=".$uniqueid."×tamp=".$timestamp."&firstname=".$firstname."&lastname=".$lastname;
$uri = $OAUTH_ENDPOINT_DOMAIN."/oauth/token";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$uri);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS,$data_string);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$result = curl_exec($ch);
$result = json_decode($result, true);
//Get Access Token on Successful Setup & Initialization of the User
$access_token = $result['access_token'];
if ($access_token != "")
{
echo "<div class='row'>".$firstname." ".$lastname." <span style='color:green;'>(Create User Success)</span<</div>";
} else {
echo "<div class='row'>".$firstname." ".$lastname." <span style='color:red;'>(Create User Failed)</span<</div>";
}
$row++;
}
fclose($handle);
}
?>
</div>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>
</body>
</html>