2015-05-21 47 views
1

設定的,但它提供的信息字段暱稱,用戶名,真實姓名,電子郵件...的Symfony2 - HWIOAuthBundle如何獲得我的,我在我的項目實施<a href="https://github.com/hwi/HWIOAuthBundle" rel="nofollow">this</a>束路徑

我還需要名字,姓氏和生日字段

如何添加或重寫這些方法?

My Settings: config.yml 


hwi_oauth: 
    firewall_name: secure_area 
    connect: 
     confirmation: false 

resource_owners: 
    facebook: 
     type:    facebook 
     client_id:   454595989899812 
     client_secret:  eba0d566631eec3e012545a5f28443dd4 
     infos_url: "https://graph.facebook.com/me?fields=id,email,first_name,last_name,gender,birthday,locale,location,picture.type(square)" 
     scope: "public_profile,user_birthday,email" 
     paths: 
      email: email 
      firstname: first_name 
      lastname: last_name 
      gender: gender 
      birthday: birthday 
      profilepicture: picture.data.url 
      locale: locale 
    google: 
     type:    google 
     client_id:   <client_id> 
     client_secret:  <client_secret> 
     #scope:    "user:email" 
fosub: 
    # try 30 times to check if a username is available (foo, foo1, foo2 etc) 
    username_iterations: 30 

    # mapping between resource owners (see below) and properties 
    properties: 
     facebook: facebook_id 
     google: google_id 

如何獲取設置路徑的值?

謝謝!

回答

1
$data = $response->getResponse(); 
... 
$data["email"]; 
$data["picture"]["data"]["url"]; 
$data['first_name']; 
$data['last_name']; 
$data['locale']; 

隨着路徑:

$response->getEmail(); 
$response->getProfilepicture(); 
$response->getFirstname(); 
$repsonse->getLastname(); 
$repsonse->getLocale(); 
+0

您好人, 隨着 「$數據= $響應 - >的GetResponse();」它工作,但是當我拿起路徑「$ Response-> getFirstName();」這是行不通的。 –

+0

錯誤消息試圖在類「HWI \ Bundle \ OAuthBundle \ OAuth \ Response \ PathUserResponse」上調用方法「getFirstname」。 你是不是要打電話給「getNickname」? –

+0

對於我跟隨的路徑[this](https://github.com/hwi/HWIOAuthBundle/blob/master/Resources/doc/internals/response_object_and_paths.md)。也許你需要駱駝案例的功能名稱。如果是這樣的話,我會爲未來的讀者更新我的答案。 – stevenll

相關問題