-
Notifications
You must be signed in to change notification settings - Fork 12
/
test_tag_v5.0.0.php
60 lines (42 loc) · 1.67 KB
/
test_tag_v5.0.0.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
<?php
require_once './src/piplapis/search.php';
function send_direct_request($email){
$url = 'https://' . getenv("PIPL_API_URL") . 'v5/';
$data = array(
'email' => $email,
'key' => getenv("PIPL_API_KEY"),
);
$data = http_build_query($data, '', '&');
$url = $url . '?' . $data;
$curl_handle=curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $url);
curl_setopt($curl_handle, CURLOPT_CONNECTTIMEOUT, 2);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($curl_handle, CURLOPT_USERAGENT, 'Your application name');
$query = curl_exec($curl_handle);
curl_close($curl_handle);
return $query;
}
function search_request($file_name, $email){
try{
PiplApi_SearchAPIRequest::get_default_configuration();
$search = new PiplApi_SearchAPIRequest(array("email" => $email));
echo "Sending request...\n";
$response = $search->send();
$json_response = json_encode($response);
echo "sending direct request...\n";
$direct_response = send_direct_request($email);
if (file_put_contents($file_name, $json_response))
echo "JSON file created successfully...\n";
else
echo "Oops! Error creating json file...\n";
if (file_put_contents("direct" . $file_name, $direct_response))
echo "direct JSON file created successfully...\n";
else
echo "Oops! Error creating direct json file...\n";
} catch (PiplApi_SearchAPIError $e) {
print $e->getMessage();
}
}
search_request("data1.json", "[email protected]");
search_request("data2.json", "[email protected]");