-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi_credentials_extractor.php
53 lines (42 loc) · 1.38 KB
/
api_credentials_extractor.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
<?php
$api_token = "null";
$base_url = "https://api.pipedrive.com/v1";
$endpoints = array("users", "deals", "persons", "notes", "products", "organizations");
function make_api_request($endpoint) {
global $base_url, $api_token;
$url = "$base_url/$endpoint?api_token=$api_token";
return file_get_contents($url);
}
function print_user_info($user_data) {
$user_data = json_decode($user_data, true);
$user_count = count($user_data["data"]);
if ($user_count === 0) {
echo "User not found.\n";
exit(0);
}
echo "User information:\n";
echo "----------------------\n";
for ($i = 0; $i < $user_count; $i++) {
$username = $user_data["data"][$i]["name"];
$email = $user_data["data"][$i]["email"];
$phone = $user_data["data"][$i]["phone"];
echo "User name: $username\n";
echo "E-Mail: $email\n";
echo "Phone: $phone\n";
echo "----------------------\n";
}
}
foreach ($endpoints as $endpoint) {
$response_data = make_api_request($endpoint);
if (empty($response_data)) {
echo "Could not get a valid response from the API.\n";
exit(1);
}
echo "API request result ($endpoint):\n";
echo "----------------------\n";
echo "$response_data\n";
echo "----------------------\n";
}
$user_response_data = make_api_request("users");
print_user_info($user_response_data);
?>