我是PHP和MySQL的新手,但我正在我的网站上实现Facebook PHP SDK.到目前为止一切正常,但我很难将用户数据添加到我的数据库(MySQL).我拥有的只是一个数字而不是用户名和oauth_uid(我得到两个字段的数字5).这是代码:
<?php
define('db_user','myUserName');
define('db_password','myPassword');
define('db_host','myHost');
define('db_name','myDbName');
// Connect to MySQL
$dbc = @mysql_connect (db_host, db_user, db_password) OR die ('Could not connect to MySQL: ' . mysql_error() );
// Select the correct database
mysql_select_db (db_name) OR die ('Could not select the database: ' . mysql_error() );
require 'lib/facebook.php';
// Create our Application instance (replace this with your appId and secret).
$facebook = new Facebook(array(
'appId' => 'MYAPPID',
'secret' => 'MYSECRET',
'cookie' => true));
// Get User ID
$user = …
Run Code Online (Sandbox Code Playgroud)