public
Created

oauth uploader sample

  • Download Gist
gistfile1.aw
PHP
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
<?php
require_once "Services/OAuthUploader.php";
$oauth = new HTTP_OAuth_Consumer('APP KEY', 'APP SECRET', 'TOKEN', 'SECRET');
$uploader = Services_OAuthUploader::factory('yfrog', $oauth);
//twitpic require api key http://dev.twitpic.com/apps/new
//$uploader = Services_OAuthUploader::factory('twitpic', $this->oauth, 'apiKey');
//proxy
//$req = new HTTP_Request2();
//$req->setConfig(array( 'proxy_host' => 'HOST', 'proxy_port' => 'PORT'));
//$uploader = Services_OAuthUploader::factory('yfrog', $oauth, null, $req);
try {
$url = $uploader->upload('/path/to/upload.jpg', 'from Services_OAuthUploader');
var_dump($url); // uploaded URL
} catch(OAuthUploader_Exception $e) {
var_dump($e);
}

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.