Skip to content

Instantly share code, notes, and snippets.

@withgod
Created December 20, 2010 06:26
Show Gist options
  • Save withgod/748086 to your computer and use it in GitHub Desktop.
Save withgod/748086 to your computer and use it in GitHub Desktop.
oauth uploader sample
<?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);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment