You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Followerwonk's Social Authority API was developed when it was a Moz
product. It used an Authorization method called MozSigned. Since
Followerwonk is no longer owned by, or associated with Moz, we've
renamed MozSigned to WonkSigned to avoid the confusion. We still accept
MozSigned, though, so existing code does not break.
The Timestamp parameter was originally called Expires, which allowed the
client to set the expiration policy. Long ago, while still a Moz
product, that strategy changed. Expires was renamed Timestamp, meant to
be the current time, allowing server-side request signature lifetime
policy management.
Just set Timestamp to the current time and if it is reasonably close to
current time when received by the server, it will be honored. A shorter
valid time window may be employed in the future.
Examples previously set a time in the future, compatible with the old
Expires policy. This update changes the examples to use current time
for all Timestamps.
Here's what each of these parts of this request do:
8
8
9
-
*`http://api.followerwonk.com`
9
+
*`http://api.followerwonk.com`
10
10
Access the API by calling the hostname of the service `api.followerwonk.com` and the Resource you’re making the request to `/social-authority`.
11
11
12
12
* {screen_name} & {user_id}
@@ -21,9 +21,9 @@ These are query parameters that provide your credentials. For example:
21
21
22
22
To use signed authentication, append the following three query string parameters:
23
23
24
-
The AccessID parameter identifies the client in question. The value of this parameter must be your access ID, obtained when you generate yourAPI credentials.
25
-
The Timestamp parameter is a Unix timestamp that indicates for how long this request is valid. This should be a time in the future, usually no more than several minutes later than the moment your client code initiates the transfer. Values that expire excessively far in the future will not be honored by the Mozscape API. Authentication timestamps must be in UTC in order to work properly.
26
-
The Signature parameter is an HMAC-SHA1 hash of your Access ID (as it appears in the AccessID parameter), followed by a new line, followed by the Timestamp parameter, using your Secret Key. This hash must be base64 and URL-encoded before being placed in the request query string.
24
+
The AccessID parameter identifies the client in question. The value of this parameter must be your access ID, obtained when you generate your API credentials.
25
+
The Timestamp parameter is a Unix timestamp and indicates when the request was signed. This should be the current time. Values that are significantly from the current time will not be honored by the Social Authority API. Authentication timestamps must be in UTC in order to work properly.
26
+
The Signature parameter is an HMAC-SHA1 hash of your Access ID (as it appears in the AccessID parameter), followed by a new line, followed by the Timestamp parameter, using your Secret Key. This hash must be Base64 and URL-encoded before being placed in the request query string.
27
27
Once combined, a valid query string should look like the following:
Once the HMAC-SHA1 of this string is created, the binary form must be base64 encoded. The result of the base64 encoding must be URL-encoded. This method of authentication is complicated, but you can find helpful examples in several languages in our Sample Code.
35
+
Once the HMAC-SHA1 of this string is created, the binary form must be Base64 encoded. The result of the Base64 encoding must be URL-encoded. This method of authentication is complicated, but you can find helpful examples in several languages in our Sample Code.
36
36
37
37
## ? and ;
38
38
39
-
These little characters are important, so don’t miss them. The ? separates the main URL from the query parameters, and the ; goes between multiple parameters. You’ll see the ; used in the example for authentication, which is just 3 parameters required by the service.
39
+
These little characters are important, so don't miss them. The ? separates the main URL from the query parameters, and the ; goes between multiple parameters. You’ll see the ; used in the example for authentication, which is just 3 parameters required by the service.
40
40
All of these elements together give you a valid request:
Copy file name to clipboardexpand all lines: docs/code-examples/perl.md
+15-15
Original file line number
Diff line number
Diff line change
@@ -23,14 +23,14 @@ Querying the Social Authority API is really quite simple. Here's an expanded exa
23
23
24
24
die "Must supply --id and --key" unless $id && $key;
25
25
26
-
my $time = time + 500;
27
-
my $signature = hmac_sha1_hex("$id\n$time", $key);
28
-
my $auth = "AccessID=$id;Timestamp=$time;Signature=$signature";
26
+
my $now = time;
27
+
my $signature = hmac_sha1_hex("$id\n$now", $key);
28
+
my $auth = "AccessID=$id;Timestamp=$now;Signature=$signature";
29
29
30
30
while ( my $names = join ',', splice @ARGV, 0,99 ) {
31
-
say http(
32
-
GET "$uri?screen_name=$names",
33
-
Authorization => "MozSigned $auth"
31
+
say http(
32
+
GET "$uri?screen_name=$names",
33
+
Authorization => "WonkSigned $auth"
34
34
)->as_json->response->dump;
35
35
}
36
36
@@ -48,30 +48,30 @@ We're stating that we'd like to use Perl 5.12.1. This version of Perl is the fir
48
48
Next we bring in the external libraries we would like to use. There are three:
49
49
50
50
use HTTP::Thin::UserAgent;
51
-
use Getopt::Long;
51
+
use Getopt::Long;
52
52
use Digest::HMAC_SHA1 qw(hmac_sha1_hex);
53
-
53
+
54
54
55
55
[`HTTP::Thin::UserAgent`][1] is a small HTTP client that makes doing API style requests easier. [`Getopt::Long`][2] is a standard command line argument parser, and it ships with the core Perl distribution. Finally [`Digest::HMAC_SHA1`][3] is what we'll use to sign our requests.
56
56
57
57
Continuing on:
58
58
59
59
die "Must supply --id and --key" unless $id && $key;
60
-
60
+
61
61
If we don't have the information we need to sign the requests we throw an exception telling the user that they need to supply the required arguments.
62
62
63
63
Next we set up our authentication credentials:
64
64
65
-
my $time = time + 500;
66
-
my $signature = hmac_sha1_hex("$id\n$time", $key);
67
-
my $auth = "AccessID=$id;Timestamp=$time;Signature=$signature";
65
+
my $now = time;
66
+
my $signature = hmac_sha1_hex("$id\n$now", $key);
67
+
my $auth = "AccessID=$id;Timestamp=$now;Signature=$signature";
68
68
69
69
Then for batches of 100 names provided on the command line, we make the API request:
70
70
71
71
while ( my $names = join ',', splice @ARGV, 0,99 ) {
0 commit comments