Giter Site home page Giter Site logo

deviant-php's Introduction

deviantPHP

Warning!

First of all: This is not an official package from http://deviantart.com.
It is a wrapper for some of theirs functions and hooks because we needed some sort of library for our project http://boxconnect.org. That said, let's see, how we can help nevertheless.

Installation

The simplest way to install the package, is via composer. Otherwise, just include() the deviantPHP.php file in the folder /src.

{
	"require": {
		"boxconnect/deviant-php": "dev-master" 
	}
}	

Quickstart:

Having installed deviantPHP via Composer, you have the extra plus of autoloading. We define DeviantPHP as namespace, thus the main class is called \DeviantPHP\DeviantPHP. Obviously, you will need to change CLIENT_ID, CLIENT_SECRET, THIS_URL AND SCOPES to suit your needs. Please see Deviantart Developer for more information.

	<?php
	require_once "vendor/autoload.php";

	use \DeviantPHP as dvp;
	$options = array("client_id" => CLIENT_ID, 
					"client_secret" => CLIENT_SECRET,
					"redirect_uri" => THIS_URL,
					"scope" => SCOPES);

	$dvpClient = new dvp\DeviantPHP($options);
	$dvpClient->authenticate();
	if ($dvpClient->isAuthenticated())
		$dvpClient->uploadFile(SOME_FILE);

	?>
  

Functions:

The following table gives an overview of the actual functions. These are subject to change, that is, some functions may be added/removed in the future.

Function Arguments Explanation
__construct() $params (array) The constructor accepts client_id, client_secret, redirect_uri, scope and user_agent as option.
authenticate none Handles the OAuth flow.
createAuthUrl none Returns the authentication URL needed for the OAuth flow.
getAccessToken $code (string) Get an access/refresh token from deviantart, needs the OAuth code as input.
refreshToken none Gets a new access token if the old one is expired (after one hour).
uploadFile $filename (string) Uploads a file to sta.sh with the given name. Returns the result (file id) as associative array.
getUser none Get infos about the authorized user.
isAuthenticated none Checks if the access token is still valid. Returns true or false.
setRedirect $url (string) Sets the redirect_uri (for OAuth).
getRedirect none Returns the actual redirect_uri.
setToken $access (string), $refresh (string) Sets the access and refresh tokens (these might come from a database/session)
getToken none Returns the tokens as an associative array (access_token, refresh_token).
setCredentials $credentials (array) Sets the client_id and client_secret ($credentials = array("client_id" => "1234", "client_secret" => "secret")
getCredentials none Returns the credentials as associative array.

Problems/Wishes

If you encounter any problems, please drop us a line at [email protected] or make a pull request.

deviant-php's People

Contributors

boxconnect avatar neighbordog avatar

Stargazers

NintenHero avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.