我正在尝试将 facebook 连接集成到我们的网站(Symfony)中,为此我们使用 FOSFacebookBundle。
我能够做到这一点并获得我的 facebook id、first_name 和 last_name,并将它们插入到我们 fos_user 列中的新用户中。
关于用户个人资料图片,我一直收到异常:
An exception occurred while executing 'INSERT INTO fos_user (username, username_canonical, email, email_canonical, enabled, salt, password, last_login, locked, expired, expires_at, confirmation_token, password_requested_at, roles, credentials_expired, credentials_expire_at, nom, prenom, solde, path, sexe, date_Naissance, facebookId, photo) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params ["1223800560964254", "1223800560964254", "******@gmail.com", "*********@gmail.com", 1, "", "", null, 0, 0, null, null, null, "a:1:{i:0;s:12:\"ROLE_PORTEUR\";}", 0, null, "Mohamed", "Elloumi", null, null, null, null, "1223800560964254", {"data":{"is_silhouette":false,"url":"https:\/\/fbcdn-profile-a.akamaihd.net\/hprofile-ak-ash2\/v\/t1.0-1\/c85.25.315.315\/s50x50\/580232_622196307791352_1230572455_n.jpg?oh=17c02ae42bb18d3ddbe3cfdf04239049&oe=57AC3250&__gda__=1474408706_227fd87692ead8189d332a4898571e62"}}]:
Notice: Array to string conversion
我认为这是因为我正在尝试将全图 api Graph 响应添加到 blob 列中:
{
"picture": {
"data": {
"is_silhouette": false,
"url": "https://fbcdn-profile-a.akamaihd.net/****"
}
},
"id": "792374454106869"
}
我想我只需要将这一行插入我的 blob 列:
"url": "https://fbcdn-profile-a.akamaihd.net/****"
我正在使用这个 php 函数插入到 fos_user 表中:
public function setFBData($fbdata) // C'est dans cette méthode que vous ajouterez vos informations
{
if (isset($fbdata['id'])) {
$this->setFacebookId($fbdata['id']);
$this->addRole('ROLE_PORTEUR');
}
if (isset($fbdata['first_name'])) {
$this->setNom($fbdata['first_name']);
}
if (isset($fbdata['last_name'])) {
$this->setPrenom($fbdata['last_name']);
}
if (isset($fbdata['email'])) {
$this->setEmail($fbdata['email']);
}
if (isset($fbdata['picture'])) {
$this->setPhoto($fbdata['picture']);
}
}