Skip to content

Commit 40b03d5

Browse files
committed
[providers/facebook] configurable fields list for Graph API request
I also removed the "privacy" field from the default fields list which is now deprecated and added the "place" field.
1 parent f772982 commit 40b03d5

File tree

3 files changed

+11
-4
lines changed

3 files changed

+11
-4
lines changed

README.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ Requirements:
1717
* PHP 5.5+
1818
* Curl library installed
1919

20-
>
20+
>
2121
* If you need PHP 5.3 support, use the 1.x version
2222
* If you need PHP 5.4 support, use the 2.x version
2323

@@ -61,7 +61,7 @@ $info->width; //The width of the embed code
6161
$info->height; //The height of the embed code
6262
$info->aspectRatio; //The aspect ratio (width/height)
6363

64-
$info->authorName; //The resource author
64+
$info->authorName; //The resource author
6565
$info->authorUrl; //The author url
6666

6767
$info->providerName; //The provider name of the page (Youtube, Twitter, Instagram, etc)
@@ -139,6 +139,7 @@ Used only for facebook events (not needed for posts, images, etc), to get inform
139139
Name | Type | Description
140140
-----|------|------------
141141
`key` | `string` | The access token used to get info from facebook graph API.
142+
`fields` | `string` | Comma-separated list of fields to query. Please refer to [Facebook documentation](https://developers.facebook.com/docs/graph-api/reference/event) for the full list of available fields.
142143

143144
## Example with all options:
144145

@@ -174,6 +175,7 @@ $info = Embed::create($url, [
174175

175176
'facebook' => [
176177
'key' => 'YOUR_KEY',
178+
'fields' => 'field1,field2,field3' // default : cover,description,end_time,id,name,owner,place,start_time,timezone
177179
],
178180
]);
179181
```

src/Embed.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ abstract class Embed
4545
'soundcloud' => [
4646
'key' => null,
4747
],
48+
49+
'facebook' => [
50+
'key' => null,
51+
'fields' => 'cover,description,end_time,id,name,owner,place,start_time,timezone'
52+
]
4853
];
4954

5055
/**
@@ -131,7 +136,7 @@ private static function process(Url $url, array $config, DispatcherInterface $di
131136
if ($adapter::check($response)) {
132137
return new $adapter($response, $config, $dispatcher);
133138
}
134-
139+
135140
if ($response->getError() === null) {
136141
$exception = new Exceptions\InvalidUrlException(sprintf("Invalid url '%s' (Status code %s)", (string) $url, $response->getStatusCode()));
137142
} else {

src/Providers/Api/Facebook.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ public function __construct(Adapter $adapter)
2424
if ($key) {
2525
$endPoint = Url::create('https://graph.facebook.com/'.$id)
2626
->withQueryParameter('access_token', $key)
27-
->withQueryParameter('fields', 'description,timezone,start_time,end_time,name,owner,privacy,id,cover');
27+
->withQueryParameter('fields', $adapter->getConfig('facebook[fields]'));
2828

2929
$response = $adapter->getDispatcher()->dispatch($endPoint);
3030

0 commit comments

Comments
 (0)