/
php.php
37 lines (28 loc) · 1.36 KB
/
php.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
<?php
$uri = 'https://api.followerwonk.com/social-authority';
// Enter your Access ID and Secret Key from http://followerwonk.com/social-authority below
$accessID = '';
$secretKey = '';
$time = time() + 500;
$signature = urlencode( base64_encode( hash_hmac( "sha1", "{$accessID}\n{$time}", $secretKey, true ) ) );
$auth = "AccessID={$accessID};Timestamp={$time};Signature={$signature}";
// Initialize an array of users. We call the API once for each of the usernames. There are more efficient alternatives.
$users = array('ebinnion', 'perigrin', 'randfish');
foreach($users as $user){
// Fetch the Json object and decode it into an array
$response = json_decode( file_get_contents( "{$uri}?screen_name={$user};{$auth}" ), true );
// Use the commented API call below to get the result returned as an object
// $response = json_decode( file_get_contents( "{$uri}?screen_name=randfish;{$auth}" ));
// Uncomment code block below to see entire Json response
// echo '<pre>';
// print_r($response);
// echo '</pre>';
// Below is an example of how to pull data out of the response array
$screen_name = $response['_embedded'][0]['screen_name'];
$user_id = $response['_embedded'][0]['user_id'];
$social_authority = $response['_embedded'][0]['social_authority'];
echo $screen_name .'<br>';
echo $user_id . '<br>';
echo $social_authority . '<br>';
}
?>