diff options
author | Brion Vibber <brion@pobox.com> | 2010-10-15 11:40:40 -0700 |
---|---|---|
committer | Brion Vibber <brion@pobox.com> | 2010-10-15 11:40:40 -0700 |
commit | 4c3aebd39644d913df4abdb69b848413ca65c298 (patch) | |
tree | 5356dcfd6f4bc43768f4b66ef4a207ac04ae1b6d /lib/oauthstore.php | |
parent | 71ed82ed9656618873dde4e41314de29158e5fe9 (diff) | |
parent | a7d98435f649da268f728825e64eb673c451e242 (diff) |
Merge branch '1.0.x' into schema-x
Diffstat (limited to 'lib/oauthstore.php')
-rw-r--r-- | lib/oauthstore.php | 30 |
1 files changed, 23 insertions, 7 deletions
diff --git a/lib/oauthstore.php b/lib/oauthstore.php index f3ee629fd..1c8e72500 100644 --- a/lib/oauthstore.php +++ b/lib/oauthstore.php @@ -55,6 +55,17 @@ class StatusNetOAuthDataStore extends OAuthDataStore } } + function getTokenByKey($token_key) + { + $t = new Token(); + $t->tok = $token_key; + if ($t->find(true)) { + return $t; + } else { + return null; + } + } + // http://oauth.net/core/1.0/#nonce // "The Consumer SHALL then generate a Nonce value that is unique for // all requests with that timestamp." @@ -317,13 +328,18 @@ class StatusNetOAuthDataStore extends OAuthDataStore function add_avatar($profile, $url) { $temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar'); - copy($url, $temp_filename); - $imagefile = new ImageFile($profile->id, $temp_filename); - $filename = Avatar::filename($profile->id, - image_type_to_extension($imagefile->type), - null, - common_timestamp()); - rename($temp_filename, Avatar::path($filename)); + try { + copy($url, $temp_filename); + $imagefile = new ImageFile($profile->id, $temp_filename); + $filename = Avatar::filename($profile->id, + image_type_to_extension($imagefile->type), + null, + common_timestamp()); + rename($temp_filename, Avatar::path($filename)); + } catch (Exception $e) { + unlink($temp_filename); + throw $e; + } return $profile->setOriginal($filename); } |