PHP code example of melsaka / imgur

1. Go to this page and download the library: Download melsaka/imgur library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

melsaka / imgur example snippets


use Melsaka\Imgur;

$credentials = [
    'username'          => '{{ your username }}',
    'client_id'         => '{{ your client_id }}',
    'client_secret'     => '{{ your client_secret }}',
    'access_token'      => '{{ your access_token }}',
    'refresh_token'     => '{{ your refresh_token }}',
];

$imgur = new Imgur($credentials);

// If $username defaulted to null then the method will return data related to the authenticated user
// $data is an associative array, for example ?query=test should be ['query' => 'test']
// For more info about what kind of $data should be sent check out: https://apidocs.imgur.com 

/** ACCOUNT SECTION **/

// Check the current rate limit status on your application.
$imgur->account()->credits();

// Generates new access token.
$imgur->account()->newToken();

// Request standard user information. 
$imgur->account()->profile($username = null);

// Returns the account settings.
$imgur->account()->settings();

// Updates the account settings.
$imgur->account()->changeSettings($data = []);

// Checks to see if account has verified its email address.
$imgur->account()->isVerified();

// Sends an email to verify that your email is valid to upload to gallery.
$imgur->account()->verify();

// Get the list of available avatars for your account.
$imgur->account()->avatars();

// Get the current account's avatar URL and avatar name.
$imgur->account()->avatar();

// Returns all of the reply notifications for your account.
$imgur->account()->replies($new = true);

// Follows the {tag}.
$imgur->account()->followTag($tag);

// Unfollows the {tag}.
$imgur->account()->unfollowTag($tag);

// Return the images the user has favorited in the gallery.
$imgur->account()->galleryFavorites($username = null, $page = 0, $sort = 'newest');

// Returns the users favorited images.
$imgur->account()->favorites($username = null, $page = 0, $sort = 'newest');

// Return the images a user has submitted to the gallery.
$imgur->account()->submissions($username = null, $page = 0, $sort = 'newest');

// List all accounts being blocked.
$imgur->account()->blocks();

// Determine if the user making the request has blocked a username.
$imgur->account()->blockStatus($username);

// Block a user.
$imgur->account()->block($username);

// Unblock a user.
$imgur->account()->unblock($username);

// Get all the images for the account that is currently authenticated.
$imgur->account()->images($page = 0);

// Return information about a specific image.
$imgur->account()->image($imageId);

// Returns an array of Image IDs that are associated with the authenticated account.
$imgur->account()->imageIds($page = 0);

// Returns the total number of images associated with the account.
$imgur->account()->imageCount();

// Deletes an Image. This up or down vote. Send veto to undo a vote.
$imgur->gallery()->vote($galleryHash, $vote);

// Get comments on an image or album in the gallery.
$imgur->gallery()->comments($galleryHash, $commentSort = 'best');

// Information about a specific comment.
$imgur->gallery()->comment($galleryHash, $commentId);

// Album / Image Comment Creation
$imgur->gallery()->commentCreate($galleryHash, $data)

// -----------------------------------------------------------

/** ALBUM SECTION **/

// Get additional information about an album.
$imgur->album()->info($albumHash);

// Return all of the images in the album.
$imgur->album()->images($albumHash);

// Get information about an image in an album.
$imgur->album()->imageInfo($albumHash, $imageHash);

// Create a new album.
$imgur->album()->create($data);

// Update the information of an album.
$imgur->album()->update($albumHash, $data);

// Delete an album with a given ID.
$imgur->album()->remove($albumHash);

// Favorite an album with a given ID.
$imgur->album()->favorite($albumHash);

// Sets the images for an album, removes all other images and only uses the images in this request.
$imgur->album()->setImages($albumHash, $data);

// Adds the images to an album.
$imgur->album()->addImages($albumHash, $data);

// Delete Images from an album.
$imgur->album()->deleteImages($albumHash, $data);

// -----------------------------------------------------------

/** Image SECTION **/

// Get information about an image.
$imgur->image()->info($imageHash);

// Upload a new image or video.
$imgur->image()->upload($data);

// Updates the title or description of an image.
$imgur->image()->update($imageHash, $data);

// Deletes an image.
$imgur->image()->remove($imageHash);

// Favorite an image with the given ID.
$imgur->image()->favorite($imageHash);

// -----------------------------------------------------------

/** COMMENT SECTION **/

// Get information about a specific comment.
$imgur->comment()->info($commentId);

// Creates a new comment, returns the ID of the comment.
$imgur->comment()->create($data);

// Delete a comment by the given id.
$imgur->comment()->remove($commentId);

// Get the comment with all of the replies for the comment.
$imgur->comment()->replies($commentId);

// Create a reply for the given comment.
$imgur->comment()->createReply($commentId, $data);

// Vote on a comment. The vote parameter can only be set as up, down, or veto.
$imgur->comment()->vote($commentId, $vote);

// Report a comment for being inappropriate.
$imgur->comment()->report($commentId);