SeeClickFix / laravel-seeclickfix-api by seeclickfix

SeeClickFix Laravel API
334
0
9
Package Data
Maintainer Username: seeclickfix
Maintainer Contact: daniel@seeclickfix.com (Daniel Stainback)
Package Create Date: 2013-10-04
Package Last Update: 2014-11-17
Home Page:
Language: PHP
License: Apache-2.0
Last Refreshed: 2024-03-28 03:10:59
Package Statistics
Total Downloads: 334
Monthly Downloads: 0
Daily Downloads: 0
Total Stars: 0
Total Watchers: 9
Total Forks: 0
Total Open Issues: 0

SeeClickFix wrapper for Laravel 4 - Alpha

Latest Stable Version Total Downloads

Laravel Seeclickfix API is a simple laravel 4 service provider (wrapper) for seeclickfix/seeclickfix-php-sdk which provides API support in PHP 5.3+


Installation

Add laravel-seeclickfix-api to your composer.json file:

"require": {
  "seeclickfix/laravel-seeclickfix-api": "dev-master"
}

Use composer to install this package.

$ composer update

Create configuration file using artisan

$ php artisan config:publish seeclickfix/laravel-seeclickfix-api

Configuration

Registering the Package

Add an alias to the bottom of app/config/app.php

'SeeClickFix' => 'SeeClickFix\API\Facade\API',

and register this service provider at the bottom of the $providers array:

'SeeClickFix\API\APIServiceProvider',

Credentials

Add your credentials to app/config/packages/seeclickfix/laravel-seeclickfix-api/config.php

return array( 
	
	/*
	 |--------------------------------------------------------------------------
	 | Settings
	 |--------------------------------------------------------------------------
	 */

    'location'	     => 'default',
    'sandbox_mode'	 => false,

	/*
	 |--------------------------------------------------------------------------
	 | Keys
	 |--------------------------------------------------------------------------
	 */

	 'client_id'      => '',
	 'client_secret'  => '',
	 'redirect_uri'   => '', // Relative path

);

When developing your application set sandbox_mode to true. This will allow you to test out features on our test server.

Usage

Basic usage

SeeClickFix::getAuthorizationUri() -This will redirect the user to the SeeClickFix authorization page.

SeeClickFix::getAccessToken() - Gets access token and validates it.

SeeClickFix::check() - Determine if the user is logged in.

SeeClickFix::getUserId( $id ) - Returns a single user by id.

SeeClickFix::logout() - Log current user out.

For a full list of API calls check the seeclickfix/seeclickfix-php-sdk wiki.

Usage examples

In your Controller use the following code:

/**
 * Login user with SeeClickFix
 *
 * @return void
 */

public function loginWithSeeClickFix() {
	
	// get data from input
	$code = Input::get( 'code' );
	
	// check if code is valid
	if ( !empty( $code ) ) 
	{
		// Try to log the user in
        SeeClickFix::getAccessToken( $code );

		return Redirect::route("/")->with("success", "You have successfully logged in.");
	}
	// if not ask for permission first
	else {
		// get SeeClickFix authorization URL
		$url = SeeClickFix::getAuthorizationUri();
		
		// return to SeeClickFix login url
		return Response::make()->header( 'Location', (string)$url );
	}

}

In your Blade Views use the following code:

@if (SeeClickFix::check())
	<li><a href="{{ route('logout') }}" class="external">Logout</a></li>
@else
	<li><a href="{{ route('login') }}" class="external">Login/Sign-up</a></li>
@endif

##License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2013-2015 SeeClickFix