将facebook个人资料图片插入blob列mysql

时间:2016-05-12 18:24:59

标签: facebook-graph-api-v2.0 fosfacebookbundle

我试图将facebook connect整合到我们的网站(Symfony)中,因此我们使用了FOSFacebookBundle。

我能够这样做并获取我的facebook id,first_name和last_name,并将它们插入到fos_user列中的新用户中。

关于用户个人资料图片,我一直收到例外:

compile 'com.android.support:appcompat-v7:23.0.1'

我认为这是因为我试图将完整图片api Graph响应添加到blob列中:

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

我想我只需要将此行插入我的blob列:

{
  "picture": {
    "data": {
      "is_silhouette": false,
      "url": "https://fbcdn-profile-a.akamaihd.net/****"
    }
  },
  "id": "792374454106869"
}

我正在使用这个php函数插入到fos_user表中:

"url": "https://fbcdn-profile-a.akamaihd.net/****"

1 个答案:

答案 0 :(得分:0)

为什么一个blob? varchar(255)应该足够用于url。你应该能够像这样访问图片数组中的url:

$fbdata['picture']['data']['url']