Skip to content

Commit f99fff0

Browse files
committed
Updated docs
1 parent 0c15d6d commit f99fff0

File tree

1 file changed

+23
-4
lines changed

1 file changed

+23
-4
lines changed

README.md

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,7 @@ Embed
44
[![Build Status](https://travis-ci.org/oscarotero/Embed.svg?branch=master)](https://travis-ci.org/oscarotero/Embed)
55
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/oscarotero/Embed/badges/quality-score.png?s=79e37032db280b9795388124c030dcf4309343d1)](https://scrutinizer-ci.com/g/oscarotero/Embed/)
66

7-
PHP library to get info and embed any web page (using oembed, opengraph, twitter-cards, scrapping the html, etc). It's compatible with any web service (youtube, vimeo, flickr, instagram, etc).
8-
Has adapters to some webpages like (archive.org, github, deviantart, etc).
7+
PHP library to get information about any web page (using oembed, opengraph, twitter-cards, scrapping the html, etc). It's compatible with any web service (youtube, vimeo, flickr, instagram, etc) and has adapters to some sites like (archive.org, github, facebook, etc).
98

109
Requirements:
1110

@@ -31,7 +30,7 @@ $info->type; //The page type (link, video, image, rich)
3130
$info->images; //List of all images found in the page
3231
$info->image; //The image choosen as main image
3332
$info->imageWidth; //The with of the main image
34-
$info->imageHeight; //The height of the main image
33+
$info->imageHeight; //The height of the main image
3534

3635
$info->code; //The code to embed the image, video, etc
3736
$info->width; //The with of the embed code
@@ -59,6 +58,7 @@ Available options
5958
* embedlyKey (string): If it's defined, get info from embedly service (only for know supported services and if the page doesn't have its own oembed service)
6059
* oembedParameters (array): Extra GET parameters to the oembed requests.
6160
* facebookProvider (bool): If it's true, the facebook provider will be used to get the page information, that uses the facebook scrapping. By default is false because reduce the number of requests and facebook scrapping not always returns right results.
61+
* request (array): Used to customize the request (see below)
6262

6363
```php
6464
$options = array(
@@ -71,9 +71,16 @@ $info = Embed\Embed::create('https://www.youtube.com/watch?v=PP1xn5wHtxE', $opti
7171
Customize the request
7272
---------------------
7373

74-
Embed provides a RequestResolvers\Curl class to resolve all requests using the curl library. You can set custom options to the curl request or use your own request resolver class creating a class implementing the RequestResolverInterface. To do that, you have the "resolver" that is an array with two values: "class" (if you want provide your own class) and "options" to set options to the curl library. The options can be any of the available in the [curl_setopt PHP function](http://php.net/manual/en/function.curl-setopt.php)
74+
Embed uses the `Embed\RequestResolvers\Curl` class to resolve all requests using the curl library. You can set options to the curl request or create your own implementation creating a class implementing the `Embed\RequestResolvers\RequestResolverInterface`.
75+
76+
The resolver configuration is defined under the "resolver" key in the options array. There is two options:
77+
78+
* class: Your custom class name if you want to use your own implementation
79+
* options: The options passed to the class. If you use the default curl class, the options are the same than the [curl_setopt PHP function](http://php.net/manual/en/function.curl-setopt.php)
7580

7681
```php
82+
//Customize the curl request of the default Embed\RequestResolvers\Curl
83+
7784
$info = Embed\Embed::create('https://www.youtube.com/watch?v=PP1xn5wHtxE', array(
7885
"resolver" => array(
7986
"options" => array(
@@ -82,6 +89,18 @@ $info = Embed\Embed::create('https://www.youtube.com/watch?v=PP1xn5wHtxE', array
8289
)
8390
)
8491
));
92+
93+
//Create your own implementation
94+
95+
$info = Embed\Embed::create('https://www.youtube.com/watch?v=PP1xn5wHtxE', array(
96+
"resolver" => array(
97+
"class" => 'My\Custom\RequestResolver'
98+
"options" => array(
99+
"option1" => "foo",
100+
"option2" => "var"
101+
)
102+
)
103+
));
85104
```
86105

87106
Online demo

0 commit comments

Comments
 (0)