martin1982/facebook-graph-sdk
PHP 7.4+ Facebook Graph SDK (v7) for accessing the Facebook Platform. Install via Composer, initialize with app ID/secret, and make Graph API requests with built-in helpers for login flows and access tokens. Includes docs and PHPUnit tests.
Extends \DateTime and represents a user's birthday returned from the Graph API which can be returned omitting certain information.
Users may opt not to share birth day or month, or may not share birth year. Possible returns:
After retrieving a GraphUser from the Graph API, the getBirthday() method will return the birthday in the form of a Facebook\GraphNode\Birthday entity which indicates which aspects of the birthday the user opted to share.
The Facebook\GraphNode\Birthday entity extends DateTime so format may be used to present the information appropriately depending on what information it contains.
Usage:
$fb = new Facebook\Facebook(\* *\);
// Returns a `Facebook\Response` object
$response = $fb->get('/me');
// Get the response typed as a GraphUser
$user = $response->getGraphUser();
// Gets birthday value, assume Graph return was format MM/DD
$birthday = $user->getBirthday();
var_dump($birthday);
// class Facebook\GraphNode\Birthday ...
var_dump($birthday->hasDate());
// true
var_dump($birthday->hasYear());
// false
var_dump($birthday->format('m/d'));
// 03/21
public boolean hasDate()
Returns whether or not the birthday object contains the day and month of birth.
public boolean hasYear()
Returns whether or not the birthday object contains the year of birth.
How can I help you explore Laravel packages today?