Question

I am creating a facebook application in Laravel 4, the problem is it is giving me following error while running as a facebook application

Symfony \ Component \ HttpKernel \ Exception \ NotFoundHttpException

but the same thing is working fine out of facebook.I followed this tutorial http://maxoffsky.com/code-blog/integrating-facebook-login-into-laravel-application/

Following is my routes.php

Route::get('home', 'HomeController@showWelcome');
Route::get('/', function() {
$facebook = new Facebook(Config::get('facebook'));
$params = array(
    'redirect_uri' => url('/login/fb/callback'),
    'scope' => 'email,publish_stream',
);
return Redirect::to($facebook->getLoginUrl($params));
}); 

Route::get('login/fb/callback', function() {
$code = Input::get('code');
if (strlen($code) == 0) return Redirect::to('/')->with('message', 'There was an error communicating with Facebook');

$facebook = new Facebook(Config::get('facebook'));
$uid = $facebook->getUser();

if ($uid == 0) return Redirect::to('/')->with('message', 'There was an error');

$me = $facebook->api('/me');

return Redirect::to('home')->with('user', $me);

});

Edit: I have checked chrome console and getting this error

Refused to display 'https://www.facebook.com/dialog/oauth?client_id=327652603940310&redirect_ur…7736c22f906b948d7eddc6a2ad0&sdk=php-sdk-3.2.3&scope=email%2Cpublish_stream' in a frame because it set 'X-Frame-Options' to 'DENY'.

No correct solution

OTHER TIPS

Put this somewhere inside bootstrap/start.php:

$app->forgetMiddleware('Illuminate\Http\FrameGuard');

You can read this post: http://forumsarchive.laravel.io/viewtopic.php?pid=65620

Try changing your callback to be Route::post not Route::get. If my memory serves me correctly, Facebook places a POST request, not a GET request.

<?php
Route::get('login/fb/callback', function() {
    $code = Input::get('code');

    if (strlen($code) == 0) {
        return Redirect::to('/')->with('message', 'There was an error communicating with Facebook');
    }

    $facebook = new Facebook(Config::get('facebook'));
    $uid = $facebook->getUser();

    if ($uid == 0) {
        return Redirect::to('/')->with('message', 'There was an error');
    }

    $me = $facebook->api('/me');

    return Redirect::to('home')->with('user', $me);

});

After looking at the link that you sent, the error actually tells you what is wrong.

REQUEST_URI /
REQUEST_METHOD  POST

Loading that page is making a POST request to /, and like I suggested above, you'll need to change the route for the index to Route::post.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top