-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathKred.php
More file actions
56 lines (42 loc) · 1.76 KB
/
Kred.php
File metadata and controls
56 lines (42 loc) · 1.76 KB
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
<?php
//Date: 18 February 2012
//Description:provides an easy to use interface for communicating with the peoplebrowsr API system.
class Kred{
private $data = Array();
public function __construct($app_id, $app_key){
//instanciation of this class will require the application id and the application key to be passed in
$this->data['app_id'] = $app_id;
$this->data['app_key'] = $app_key;
$this->data['url'] = 'http://api.kred.ly';
}
public function execute($method,$parameters){
//the method parameter of this function relates to the API method to be invoked.
//A complete list of available methods and associated parameters can be found at: https://developer.peoplebrowsr.com/kred.
//this function will accept an array of paramters making it consistent with other functions of this class.
//required paramters are term and source. these terms should be the indexes of the array passed in.
/*
as of the date of publication of this library, the kred API includes methods of kredscore and kred
kred method parameters in addtion to app_id and app_key
source*
term*
kredscore method parameters in addtion to app_id and app_key
source*
term*
*denotes required parameters
*/
$URL = $this->data['url'].'/'.$method.'?';
$QueryString = "app_id=" . $this->data['app_id'];
$QueryString .= "&app_key=" . $this->data['app_key'];
foreach($parameters as $k => $v){
$QueryString .= '&'.$k.'='.urlencode($v);
}
$URL .= $QueryString;
$curl_handle = curl_init();
curl_setopt($curl_handle, CURLOPT_URL, $URL);
curl_setopt($curl_handle, CURLOPT_RETURNTRANSFER, 1);
$response = curl_exec($curl_handle);
curl_close($curl_handle);
return $response;
}
}
?>