【问题标题】:Local facebook testing本地脸书测试
【发布时间】:2014-11-19 17:53:56
【问题描述】:

我无法进行本地 facebook 测试。

我已经将/etc/hosts 中的应用程序命名为superapp.app,并将路径从 localhost 更改为 superapp.app

我正在使用 Hybridauth 对用户进行身份验证。当我身份验证失败! Facebook 返回了无效的用户 ID。在应用程序窗口打开并要求我提交我的个人资料后,它会在重定向时发生!

我猜这与 Facebook 的应用设置有关。

在 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');
    }

}

我的路线.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 测试中做错了什么?我已经重置了应用程序密码,并且我确信该错误是由于 facebook 应用程序测试设置造成的。为了使它工作,我必须在我的本地计算机上创建 SSL。我该怎么做呢?我还将我的公共 IP 添加到服务器白名单中。

【问题讨论】:

  • 添加一些调试代码并找出用户 ID 实际是什么。您使用的 SDK 可能不适用于最近的 Graph API 更改。使用 SDK 从 Facebook 获取的 FB ID 更新您的答案。

标签: facebook testing laravel facebook-php-sdk


【解决方案1】:

好的,我有解决方案:如果不使用 Homestead for Laravel,它将无法工作,您可能不再禁用 SSL。

您需要安装虚拟机。

【讨论】:

    猜你喜欢
    • 2012-12-28
    • 1970-01-01
    • 2019-10-27
    • 1970-01-01
    • 2015-03-16
    • 2016-06-09
    • 2012-07-05
    • 1970-01-01
    • 2014-07-05
    相关资源
    最近更新 更多