我无法让本地的facebook测试工作。
我已将/etc/hosts
中的应用命名为superapp.app
,我将路径从localhost更改为superapp.app
我正在使用Hybridauth对用户进行身份验证。当我的身份验证失败! Facebook返回了无效的用户ID。在应用程序窗口打开后,我被要求提交我的个人资料,它会在重定向时发生!
我想这与Facebook的App设置有关。
在base_facebook.php中我有:
/**
* Default options for curl.
*
* @var array
*/
public static $CURL_OPTS = array(
CURLOPT_CONNECTTIMEOUT => 50,
CURLOPT_RETURNTRANSFER => true,
CURLOPT_TIMEOUT => 60,
CURLOPT_USERAGENT => 'facebook-php-3.2',
CURLOPT_SSL_VERIFYPEER => false,
CURLOPT_SSL_VERIFYHOST => false,
);
/**
* Indicates if we trust HTTP_X_FORWARDED_* headers.
*
* @var boolean
*/
protected $trustForwarded = true;
/**
* Indicates if signed_request is allowed in query parameters.
*
* @var boolean
*/
protected $allowSignedRequest = false;
<?php
return array(
"base_url" => "http://localhost:8000/fbauth/auth",
"providers" => array (
"Facebook" => array (
"enabled" => TRUE,
"keys" => array ("id" => "787714197957925", "secret" =>
"mysecret"),
"scope" => "email",
"trustForwarded" => true,
)
)
);
oauth.php
<?php
return array(
"base_url" => "http://localhost:8000/oauth/auth",
"providers" => array (
"Facebook" => array (
"enabled" => TRUE,
"keys" => array ("id" => "787714197957925", "secret"
=> "mysecret"),
"scope" => "email",
),
)
);
我只有标准的用户模型。
<?php
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Database\Migrations\Migration;
class CreateUsersTable extends Migration {
/**
* Run the migrations.
*
* @return void
*/
public function up()
{
Schema::create('users', function($table)
{
$table->increments('id');
$table->string('email');
$table->string('password', 64);
$table->string('name');
$table->boolean('admin');
$table->timestamps();
});
}
/**
* Reverse the migrations.
*
* @return void
*/
public function down()
{
Schema::drop('users');
}
}
我的routes.php
Route::get('facebook', function()
{
return "<a href='fbauth'>Login with Facebook</a>";
});
Route::get('fbauth/{auth?}', function($auth = NULL)
{
if ($auth == 'auth') {
try {
Hybrid_Endpoint::process();
} catch (Exception $e) {
return Redirect::to('fbauth');
}
return;
}
try {
$oauth = new Hybrid_Auth(app_path()
. '/config/fb_auth.php');
$provider = $oauth->authenticate('Facebook');
$profile = $provider->getUserProfile();
}
catch(Exception $e) {
return $e->getMessage();
}
echo 'Welcome ' . $profile->firstName . ' '
. $profile->lastName . '
';
echo 'Your email: ' . $profile->email . '
';
dd($profile);
});
我的应用设置:
我在本地的facebook测试中做错了什么?我已经重置了app秘密,我确信错误是由于facebook app测试设置造成的。为了使其工作,我将不得不在我的本地计算机上创建SSL。我该怎么做呢?我还将我的公共IP添加到服务器白名单。
答案 0 :(得分:0)
好的,我有解决方案:如果不使用Homestead for Laravel,它将无法运行,您可能无法再禁用SSL。
您需要安装虚拟机。