Reputation: 217
Hi i am laravel 4 begginer.
i try to use Artadek/OAuth-4-laravel package Everything went well untill using the example what i did:
Route:
Route::get('lfb', array(
'as' => 'lfb',
'uses' => 'HomeController@signInWithFacebook'
));
Controller:
class HomeController extends BaseController {
public function signInWithFacebook() {
// get data from input
$code = Input::get( 'code' );
// get fb service
$fb = OAuth::consumer( 'Facebook' );
// check if code is valid
// if code is provided get user data and sign in
if ( !empty( $code ) ) {
// This was a callback request from facebook, get the token
$token = $fb->requestAccessToken( $code );
// Send a request with it
$result = json_decode( $fb->request( '/me' ), true );
$message = 'Your unique facebook user id is: ' . $result['id'] . ' and your name is ' . $result['name'];
echo $message. "<br/>";
//Var_dump
//display whole array().
dd($result);
}
// if not ask for permission first
else {
// get fb authorization
$url = $fb->getAuthorizationUri();
// return to facebook login url
return Redirect::to( (string)$url );
}
}
And blade :
@extends('layout.main')
@section('content')
<a href="{{ URL::route('lfb') }}">Sign in with Facebook</a>
@stop
Last error log from laravel.log:
Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException
open: F:\wamp\www\IbidsLR\bootstrap\compiled.php
{
$routes = $this->get($request->getMethod());
$route = $this->check($routes, $request);
if (!is_null($route)) {
return $route->bind($request);
}
$this->checkForAlternateVerbs($request);
throw new NotFoundHttpException();
}
protected function checkForAlternateVerbs($request)
And i get when press on the button "Whoops,somthing went wrong." and it redirect me to lfb page which i dont have any page called that name i just want to use fb login..
What wrong here?
Upvotes: 0
Views: 240
Reputation: 1570
Goes to your laravel folder, then open app/config/app.php
and make sure 'debug' => 'true'
and it will help you showing what kinds of error you are having now.
It is working fine with your routes and also signInWithFacebook()
function. Make sure that you already created a config file for Artadek/OAuth-4-laravel
package, and it will be in app/config/packages
.
It is showing lfb page because that is your route -- your function will be working with it.
Please make sure debug is on and check your error again. It is hard to explain with just that 'Whoops, something went wrong.'
Upvotes: 1