Skip to content

Instantly share code, notes, and snippets.

@imranrbx
Last active November 11, 2017 14:26
Show Gist options
  • Save imranrbx/c05683805127086d71f38e5cdc7daecd to your computer and use it in GitHub Desktop.
Save imranrbx/c05683805127086d71f38e5cdc7daecd to your computer and use it in GitHub Desktop.
<?php
namespace App\SocialMedia;
class Facebook{
protected $client_id;
private $client_secret;
public $redirect_url;
public function __construct($facebook){
$this->client_id = $facebook['client_id'];
$this->client_secret = $facebook['client_secret'];
$this->redirect_url = $facebook['redirect'];
}
public function getClientID(){
return $this->client_id;
}
public function getClientSecret(){
return $this->client_secret;
}
public function getRedirectURL(){
return $this->redirect_url;
}
}
<?php
namespace App\Providers;
use Illuminate\Support\ServiceProvider;
use App\SocialMedia\Facebook;
class FacebookServiceProvider extends ServiceProvider
{
/**
* Bootstrap the application services.
*
* @return void
*/
public function boot()
{
//
}
/**
* Register the application services.
*
* @return void
*/
public function register()
{
$this->app->bind("App\SocialMedia\Facebook", function(){
return new Facebook(config('services.facebook'));
});
$this->app->make("App\SocialMedia\Facebook");
}
}
<?php
namespace App\Http\Controllers;
use App\Http\Controllers\Controller;
use App\Post;
use App\User;
use Illuminate\Http\Request;
use DB;
use Auth;
use Facebook;
class PostController extends Controller
{
/**
* Display a listing of the resource.
*
* @return \Illuminate\Http\Response
*/
public function index(Facebook $fb){
dd($fb);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment