Esempio n. 1
0
 * @copyright (c) 2013 bndr
 * @license http://creativecommons.org/licenses/by-sa/3.0/legalcode
 */
//Include the main file
include "Imgur.php";
//Set up your api key and secret
$api_key = "";
$api_secret = "";
$imgur = new Imgur($api_key, $api_secret);
/*-----------------------------------------------------------------------------------*/
/* Authorization
/*-----------------------------------------------------------------------------------*/
//We create a new instance of imgur class.
// Imgur oAuth will return code as GET parameter after the user allows access
if (isset($_GET['code'])) {
    $tokens = $imgur->authorize(false, $_GET['code']);
    //First parameter is for refresh_tokens
    //The user is authorized. You can save the $tokens['refresh_token'] and $tokens['access_token'] for future use;
} else {
    // GET parameter doesn't exist, so we will have to ask user to allow access for our application
    $imgur->authorize();
}
/*-----------------------------------------------------------------------------------*/
/* Account
/*-----------------------------------------------------------------------------------*/
$imgur->account("username")->basic();
$imgur->account("username")->albums($page = 0);
$imgur->account("username")->images($page = 0);
$imgur->account("new_username")->create($options);
//$options will be used as post fields. For more info go to Imgur API Docs.
//....