Skip to content

Commit 5ba36bc

Browse files
Soner Yilmazoyvindkinsey
Soner Yilmaz
authored andcommitted
Add support to PHP SDK for graph-video.facebook.com endpoint
1 parent b8dc052 commit 5ba36bc

File tree

1 file changed

+23
-1
lines changed

1 file changed

+23
-1
lines changed

src/base_facebook.php

+23-1
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,7 @@ abstract class BaseFacebook
150150
'api_video' => 'https://api-video.facebook.com/',
151151
'api_read' => 'https://api-read.facebook.com/',
152152
'graph' => 'https://graph.facebook.com/',
153+
'graph_video' => 'https://graph-video.facebook.com/',
153154
'www' => 'https://www.facebook.com/',
154155
);
155156

@@ -750,6 +751,21 @@ protected function _restserver($params) {
750751
return $result;
751752
}
752753

754+
/**
755+
* Return true if this is video post.
756+
*
757+
* @param string $path The path
758+
* @param string $method The http method (default 'GET')
759+
*
760+
* @return boolean true if this is video post
761+
*/
762+
protected function isVideoPost($path, $method = 'GET') {
763+
if ($method == 'POST' && preg_match("/^(\/)(.+)(\/)(videos)$/", $path)) {
764+
return true;
765+
}
766+
return false;
767+
}
768+
753769
/**
754770
* Invoke the Graph API.
755771
*
@@ -767,8 +783,14 @@ protected function _graph($path, $method = 'GET', $params = array()) {
767783
}
768784
$params['method'] = $method; // method override as we always do a POST
769785

786+
if ($this->isVideoPost($path, $method)) {
787+
$domainKey = 'graph_video';
788+
} else {
789+
$domainKey = 'graph';
790+
}
791+
770792
$result = json_decode($this->_oauthRequest(
771-
$this->getUrl('graph', $path),
793+
$this->getUrl($domainKey, $path),
772794
$params
773795
), true);
774796

0 commit comments

Comments
 (0)