Skip to content

Commit

Permalink
Add support to PHP SDK for graph-video.facebook.com endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
Soner Yilmaz authored and oyvindkinsey committed Jan 23, 2012
1 parent b8dc052 commit 5ba36bc
Showing 1 changed file with 23 additions and 1 deletion.
24 changes: 23 additions & 1 deletion src/base_facebook.php
Expand Up @@ -150,6 +150,7 @@ abstract class BaseFacebook
'api_video' => 'https://api-video.facebook.com/',
'api_read' => 'https://api-read.facebook.com/',
'graph' => 'https://graph.facebook.com/',
'graph_video' => 'https://graph-video.facebook.com/',
'www' => 'https://www.facebook.com/',
);

Expand Down Expand Up @@ -750,6 +751,21 @@ protected function _restserver($params) {
return $result;
}

/**
* Return true if this is video post.
*
* @param string $path The path
* @param string $method The http method (default 'GET')
*
* @return boolean true if this is video post
*/
protected function isVideoPost($path, $method = 'GET') {
if ($method == 'POST' && preg_match("/^(\/)(.+)(\/)(videos)$/", $path)) {
return true;
}
return false;
}

/**
* Invoke the Graph API.
*
Expand All @@ -767,8 +783,14 @@ protected function _graph($path, $method = 'GET', $params = array()) {
}
$params['method'] = $method; // method override as we always do a POST

if ($this->isVideoPost($path, $method)) {
$domainKey = 'graph_video';
} else {
$domainKey = 'graph';
}

$result = json_decode($this->_oauthRequest(
$this->getUrl('graph', $path),
$this->getUrl($domainKey, $path),
$params
), true);

Expand Down

0 comments on commit 5ba36bc

Please sign in to comment.