-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathphotos_addTags.php
50 lines (41 loc) · 1.46 KB
/
photos_addTags.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
<?php
function photos_addTags($photo_id, $tags)
{
$oauth_nonce = md5(uniqid(rand(), true));
$now = time();
$method = 'flickr.photos.addTags';
$params =
"format=json" .
"&method=" . $method .
"&nojsoncallback=1" .
"&oauth_consumer_key=" . api_key .
"&oauth_nonce=" . $oauth_nonce .
"&oauth_signature_method=" . oauth_signature_method .
"&oauth_timestamp=" . $now .
"&oauth_token=" . src_oauth_token .
"&oauth_version=" . oauth_version .
"&photo_id=" . $photo_id .
"&tags=" . rawurlencode($tags);
$base_string = 'POST&'. urlencode(api_endpoint) . '&' . urlencode($params);
$hash_key = api_secret . '&' . src_oauth_token_secret;
$oauth_sig = base64_encode(hash_hmac('sha1', $base_string, $hash_key, true));
$params .= '&oauth_signature=' . $oauth_sig;
$args = array(
'format' => 'json',
'method' => $method,
'nojsoncallback' => 1,
'oauth_consumer_key' => api_key,
'oauth_nonce' => $oauth_nonce,
'oauth_signature_method' => oauth_signature_method,
'oauth_timestamp' => $now,
'oauth_token' => src_oauth_token,
'oauth_version' => oauth_version,
'photo_id' => $photo_id,
'tags' => rawurlencode($tags),
'oauth_signature' => $oauth_sig,
);
if (debug) {
error_log("*** addTags *** \n", 3, log_path);
}
return http_request(api_endpoint, $params, $args, 'POST');
}