File tree Expand file tree Collapse file tree 10 files changed +23
-12
lines changed Expand file tree Collapse file tree 10 files changed +23
-12
lines changed Original file line number Diff line number Diff line change @@ -19,7 +19,7 @@ public function getEndPoint()
19
19
{
20
20
return Url::create (static ::$ endPoint )
21
21
->withQueryParameters ([
22
- 'url ' => (string ) $ this ->response -> getUrl (),
22
+ 'url ' => (string ) $ this ->getUrl (),
23
23
'format ' => 'json ' ,
24
24
'for ' => 'embed ' ,
25
25
]);
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ public function getEndPoint()
42
42
{
43
43
return Url::create ('http://api.embed.ly/1/oembed ' )
44
44
->withQueryParameters ([
45
- 'url ' => (string ) $ this ->response -> getUrl (),
45
+ 'url ' => (string ) $ this ->getUrl (),
46
46
'format ' => 'json ' ,
47
47
'key ' => $ this ->key ,
48
48
]);
Original file line number Diff line number Diff line change 12
12
abstract class EndPoint
13
13
{
14
14
protected $ response ;
15
+ protected $ url ;
15
16
protected static $ pattern ;
16
17
protected static $ endPoint ;
17
18
@@ -25,16 +26,21 @@ public static function create(Adapter $adapter)
25
26
if ($ response ->getUrl ()->match (static ::$ pattern )) {
26
27
return new static ($ response );
27
28
}
29
+
30
+ if ($ response ->getStartingUrl ()->match (static ::$ pattern )) {
31
+ return new static ($ response , $ response ->getStartingUrl ());
32
+ }
28
33
}
29
34
30
35
/**
31
36
* Constructor.
32
37
*
33
38
* @param Response $response
34
39
*/
35
- protected function __construct (Response $ response )
40
+ protected function __construct (Response $ response, Url $ url = null )
36
41
{
37
42
$ this ->response = $ response ;
43
+ $ this ->url = $ url ;
38
44
}
39
45
40
46
/**
@@ -44,8 +50,13 @@ public function getEndPoint()
44
50
{
45
51
return Url::create (static ::$ endPoint )
46
52
->withQueryParameters ([
47
- 'url ' => (string ) $ this ->response -> getUrl (),
53
+ 'url ' => (string ) $ this ->getUrl (),
48
54
'format ' => 'json ' ,
49
55
]);
50
56
}
57
+
58
+ public function getUrl ()
59
+ {
60
+ return $ this ->url ?: $ this ->response ->getUrl ();
61
+ }
51
62
}
Original file line number Diff line number Diff line change @@ -13,14 +13,14 @@ class Facebook extends EndPoint implements EndPointInterface
13
13
*/
14
14
public function getEndPoint ()
15
15
{
16
- if ($ this ->response -> getUrl ()->match (['*/videos/* ' , '/video.php ' ])) {
16
+ if ($ this ->getUrl ()->match (['*/videos/* ' , '/video.php ' ])) {
17
17
$ endPoint = Url::create ('https://www.facebook.com/plugins/video/oembed.json ' );
18
18
} else {
19
19
$ endPoint = Url::create ('https://www.facebook.com/plugins/post/oembed.json ' );
20
20
}
21
21
22
22
return $ endPoint ->withQueryParameters ([
23
- 'url ' => (string ) $ this ->response -> getUrl (),
23
+ 'url ' => (string ) $ this ->getUrl (),
24
24
'format ' => 'json ' ,
25
25
]);
26
26
}
Original file line number Diff line number Diff line change @@ -42,7 +42,7 @@ public function getEndPoint()
42
42
{
43
43
return Url::create ('http://open.iframe.ly/api/oembed ' )
44
44
->withQueryParameters ([
45
- 'url ' => (string ) $ this ->response -> getUrl (),
45
+ 'url ' => (string ) $ this ->getUrl (),
46
46
'format ' => 'json ' ,
47
47
'api_key ' => $ this ->key ,
48
48
]);
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class Infogram extends EndPoint implements EndPointInterface
17
17
*/
18
18
public function getEndPoint ()
19
19
{
20
- $ url = $ this ->response -> getUrl ()->withScheme ('https ' );
20
+ $ url = $ this ->getUrl ()->withScheme ('https ' );
21
21
22
22
return Url::create (static ::$ endPoint )
23
23
->withQueryParameters ([
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class Instagram extends EndPoint implements EndPointInterface
17
17
*/
18
18
public function getEndPoint ()
19
19
{
20
- $ url = $ this ->response -> getUrl ()->withScheme ('http ' );
20
+ $ url = $ this ->getUrl ()->withScheme ('http ' );
21
21
22
22
return Url::create (static ::$ endPoint )
23
23
->withQueryParameters ([
Original file line number Diff line number Diff line change @@ -14,7 +14,7 @@ class Jsbin extends EndPoint implements EndPointInterface
14
14
*/
15
15
public function getEndPoint ()
16
16
{
17
- $ url = $ this ->response -> getUrl ()->withDirectoryPosition (2 , 'embed ' );
17
+ $ url = $ this ->getUrl ()->withDirectoryPosition (2 , 'embed ' );
18
18
19
19
return Url::create (static ::$ endPoint )
20
20
->withQueryParameters ([
Original file line number Diff line number Diff line change @@ -17,7 +17,7 @@ class Scribd extends EndPoint implements EndPointInterface
17
17
*/
18
18
public function getEndPoint ()
19
19
{
20
- $ url = $ this ->response -> getUrl ()->withDirectoryPosition (0 , 'doc ' );
20
+ $ url = $ this ->getUrl ()->withDirectoryPosition (0 , 'doc ' );
21
21
22
22
return Url::create (static ::$ endPoint )
23
23
->withQueryParameters ([
Original file line number Diff line number Diff line change @@ -16,7 +16,7 @@ public function getEndPoint()
16
16
{
17
17
return Url::create (static ::$ endPoint )
18
18
->withQueryParameters ([
19
- 'url ' => (string ) $ this ->response -> getUrl ()->withQueryParameters ([]),
19
+ 'url ' => (string ) $ this ->getUrl ()->withQueryParameters ([]),
20
20
'format ' => 'json '
21
21
]);
22
22
}
You can’t perform that action at this time.
0 commit comments