Skip to content

Commit bb59e20

Browse files
committed
min fixed, added provider access docs
1 parent 83a563c commit bb59e20

File tree

3 files changed

+33
-22
lines changed

3 files changed

+33
-22
lines changed

README.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -136,23 +136,6 @@ Used only for soundcloud pages, to get information using its api.
136136
* key (string): to get info from soundcloud API.
137137

138138

139-
```php
140-
$config = [
141-
'providers' => [
142-
'oembed' => [
143-
'parameters' => [],
144-
'embedlyKey' => null
145-
],
146-
'html' => [
147-
'maxImages' => -1
148-
],
149-
'facebook' => [
150-
'key' => 'our-access-token'
151-
]
152-
]
153-
];
154-
```
155-
156139
### The request resolver
157140

158141
Embed uses the `Embed\RequestResolvers\Curl` class to resolve all requests using the curl library. You can set options to the curl request or use your custom resolver creating a class implementing the `Embed\RequestResolvers\RequestResolverInterface`.
@@ -243,7 +226,8 @@ $config = [
243226
[You can see here](https://github.com/oscarotero/Embed/tree/master/src/ImageInfo) the ImageInfo implementations included.
244227

245228

246-
### Example
229+
### Configuration example
230+
247231

248232
```php
249233
$config = [
@@ -259,8 +243,15 @@ $config = [
259243
]
260244
],
261245
'providers' => [
246+
'oembed' => [
247+
'parameters' => [],
248+
'embedlyKey' => null
249+
],
262250
'html' => [
263251
'maxImages' => 3
252+
],
253+
'facebook' => [
254+
'key' => 'our-access-token'
264255
]
265256
],
266257
'resolver' => [
@@ -274,3 +265,23 @@ $config = [
274265
]
275266
];
276267
```
268+
269+
### Access to more data
270+
271+
As said before, the adapter get the data from all providers and choose the best values. But you can get the data directly from the providers, useful if you want to get the specific value returned by any provider.
272+
273+
```php
274+
use Embed\Embed;
275+
276+
//Get the info
277+
$info = Embed::create('https://www.youtube.com/watch?v=PP1xn5wHtxE');
278+
279+
//Get the oembed provider
280+
$oembed = $info->getProvider('oembed');
281+
282+
//Get the oembed title:
283+
echo $oembed->getTitle();
284+
285+
//Get any value returned by oembed api
286+
$echo $oembed->bag->get('author_name');
287+
```

src/Providers/Html.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,12 +70,12 @@ public function getType()
7070
*/
7171
public function getTags()
7272
{
73-
$keywords = $this->bag->get('keywords');
74-
75-
if (!$keywords) {
73+
if (!$this->bag->has('keywords')) {
7674
return [];
7775
}
7876

77+
$keywords = $this->bag->get('keywords');
78+
7979
//some sites, contains the keywords separated by commas
8080
if (strpos($keywords, ',')) {
8181
$keywords = explode(',', $keywords);

src/Providers/OpenGraph.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ public function getUrl()
133133
*/
134134
public function getTags()
135135
{
136-
return $this->bag->get('tags') ?: [];
136+
return (array) $this->bag->get('tags') ?: [];
137137
}
138138

139139
/**

0 commit comments

Comments
 (0)