本文整理汇总了PHP中http::proceed_natively方法的典型用法代码示例。如果您正苦于以下问题:PHP http::proceed_natively方法的具体用法?PHP http::proceed_natively怎么用?PHP http::proceed_natively使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类http
的用法示例。
在下文中一共展示了http::proceed_natively方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: get_view_text_extension
/**
* display available recording, if any
*
* This function retrieves the list of available recordings from the BBB server,
* and displays it to the surfer.
*/
function get_view_text_extension()
{
global $context;
// parameters to list recordings
$parameters = array();
$parameters[] = 'meetingID=' . urlencode($this->attributes['id']);
// link to list recordings
$url = $this->build_link('getRecordings', $parameters);
// query the BBB back-end
if (($response = http::proceed_natively($url)) && ($xml = simplexml_load_string($response)) && $xml->returncode == 'SUCCESS') {
// ok, we have some recording available
if ($recordings = $xml->recordings->children()) {
// enumerate recordings, but use only the first one
foreach ($recordings as $name => $node) {
// sanity checks
if ($name != 'recording') {
continue;
}
if (!isset($node->playback)) {
continue;
}
if (!isset($node->playback->format)) {
continue;
}
if (!isset($node->playback->format->url)) {
continue;
}
// a button to start the replay in a separate window
$menu = array();
$menu[] = Skin::build_link((string) $node->playback->format->url, 'Play the presentation', 'tee');
return Skin::build_box('Presentation', Skin::finalize_list($menu, 'menu_bar'));
}
}
}
}
示例2: get_start_url
/**
* the URL to start and to join the event
*
* @see overlays/events/start.php
*
* @return string the URL to redirect the user to the meeting, or NULL on error
*/
function get_start_url()
{
global $context;
// create an OpenTok session
if (isset($context['opentok_api_key']) && $context['opentok_api_key']) {
// server to connect to
if (isset($context['opentok_api_url']) && $context['opentok_api_url']) {
$url = $context['opentok_api_url'];
} else {
$url = 'https://staging.tokbox.com/hl';
}
// link to create a session
$url .= '/session/create';
// authenticate through HTTP headers
$headers = array('X-TB-PARTNER-AUTH: ' . $context['opentok_api_key'] . ':' . $context['opentok_api_secret']);
// parameters of this session
$parameters = array();
$parameters['api_key'] = $context['opentok_api_key'];
$parameters['location'] = $_SERVER['REMOTE_ADDR'];
// get a new session id
if ($response = http::proceed_natively($url, $headers, $parameters)) {
// invalid xml response
if (!($xml = @simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA))) {
Logger::error(sprintf('OpenTok: %s', 'response is not valid XML'));
return NULL;
// error code returned by the server
} elseif ($errors = $xml->xpath("//error")) {
if ($message = $errors[0]->xpath("//@message")) {
$message = (string) $message[0]['message'];
} else {
$message = 'unknown error';
}
Logger::error(sprintf('OpenTok: %s', $xml->error['code'] . ' ' . $xml->error->children()->getName() . ': ' . $message));
return NULL;
// no session id in the response
} elseif (!isset($xml->Session->session_id)) {
Logger::error(sprintf('OpenTok: %s', 'no session id has been provided'));
return NULL;
}
// save the session id along averlay data and forward it to all participants
$fields = array('session_id' => (string) $xml->Session->session_id);
$this->set_values($fields);
}
}
// redirect to the main page
if (is_object($this->anchor)) {
return $context['url_to_home'] . $context['url_to_root'] . $this->anchor->get_url();
}
// problem, darling!
return NULL;
}
示例3: oembed
/**
* use oEmbed to embed some object
*
* @link http://oembed.com/ the specification of the oEmbed protocol
*
* The strategy to find oEmbed data is the following:
* - list of well-known services (e.g., slideshare, ...)
* - sense the target url in case an oEmbed endpoint is provided
* - submit the url to http://www.noembed.com/
*
* The array returned reflects the outcome of the oEmbed transaction.
* If a network error takes place, the type is set to 'error'.
*
* @param string the address of the object to embed
* @return array attributes returned by provider
*/
public static function oembed($url)
{
global $context;
// we return an array of results
$result = array();
// the list of known endpoints
$endpoints = array();
// type: video
$endpoints['https?://(www\\.)?youtube\\.com/watch\\?'] = 'http://www.youtube.com/oembed';
$endpoints['http://youtu\\.be/'] = 'http://www.youtube.com/oembed';
$endpoints['https?://(www\\.)?vimeo\\.com/'] = 'http://vimeo.com/api/oembed.json';
$endpoints['http://revision3\\.com/'] = 'http://revision3.com/api/oembed/';
$endpoints['http://(www\\.)?5min\\.com/video/'] = 'http://api.5min.com/oembed.json';
$endpoints['http://(www\\.)?dotsub\\.com/view/'] = 'http://dotsub.com/services/oembed';
$endpoints['https?://(www\\.)?hulu\\.com/watch/'] = 'http://www.hulu.com/api/oembed.json';
$endpoints['https?://(www\\.)?dailymotion\\.com/'] = 'http://www.dailymotion.com/services/oembed/';
$endpoints['http://[^\\.]+\\.blip\\.tv/'] = 'http://blip.tv/oembed/';
$endpoints['http://blip\\.tv/'] = 'http://blip.tv/oembed/';
$endpoints['https?://(www\\.)?viddler\\.com/'] = 'http://lab.viddler.com/services/oembed/';
// type: photo (or file)
$endpoints['https?://(www\\.)?flickr\\.com/'] = 'http://www.flickr.com/services/oembed/';
$endpoints['http://flic\\.kr/'] = 'http://www.flickr.com/services/oembed/';
$endpoints['http://[^\\.]+\\.deviantart\\.com/'] = 'http://backend.deviantart.com/oembed';
$endpoints['http://yfrog\\.'] = 'http://www.yfrog.com/api/oembed';
$endpoints['https?://(www\\.)?smugmug\\.com/'] = 'http://api.smugmug.com/services/oembed/';
$endpoints['http://[^\\.]+\\.photobucket\\.com/'] = 'http://photobucket.com/oembed';
// type: rich
$endpoints['https?://[^\\.]+\\.twitter\\.com/.+?/status(es)?/'] = 'https://api.twitter.com/1/statuses/oembed.json';
$endpoints['https?://twitter\\.com/.+?/status(es)?/'] = 'https://api.twitter.com/1/statuses/oembed.json';
$endpoints['http://official\\.fm/'] = 'http://official.fm/services/oembed.json';
$endpoints['http://soundcloud\\.com/'] = 'http://soundcloud.com/oembed';
$endpoints['http://rd\\.io/'] = 'http://www.rdio.com/api/oembed/';
$endpoints['https?://(www\\.)?slideshare\\.net/'] = 'http://www.slideshare.net/api/oembed/2';
$endpoints['https?://(www\\.)?scribd\\.com/'] = 'http://www.scribd.com/services/oembed';
// look at each providers
$endpoint = null;
foreach ($endpoints as $pattern => $api) {
// stop when one provider has been found
if (preg_match('/' . str_replace('/', '\\/', $pattern) . '/i', $url)) {
$endpoint = $api;
break;
}
}
// finalize the query for the matching endpoint
if ($endpoint) {
// prepare the oEmbed request
$parameters = array();
$parameters[] = 'url=' . urlencode($url);
$parameters[] = 'maxwidth=500';
$parameters[] = 'format=json';
// encode provided data, if any
$endpoint .= '?' . implode('&', $parameters);
// else try to auto-detect an endpoint
} elseif ($content = http::proceed_natively($url)) {
// it is not necessary to look at page content
$content = substr($content, 0, stripos($content, '</head>'));
// if the endpoint signature is found
if (stripos($content, 'application/json+oembed') !== FALSE) {
// extract all links
if (preg_match_all('/<link([^<>]+)>/i', $content, $links)) {
// look at each of them sequentially
foreach ($links[1] as $link) {
// not the oEmbed endpoint!
if (!stripos($link, 'application/json+oembed')) {
continue;
}
// got it!
if (preg_match('/href="([^"]+)"/i', $link, $matches)) {
$endpoint = trim($matches[1]);
break;
}
}
}
}
}
// if no provider has been found, submit this url to noembed.com
if (!$endpoint) {
// prepare the oEmbed request
$parameters = array();
$parameters[] = 'url=' . urlencode($url);
$parameters[] = 'maxwidth=500';
$parameters[] = 'format=json';
// encode provided data, if any
$endpoint = 'http://noembed.com/embed?' . implode('&', $parameters);
//.........这里部分代码省略.........
示例4: release
/**
* stop a phone call
*
* @param array e.g., array('call_id' => '123')
* @return mixed some error array with code and message, or the id of the stopped call
*/
function release($parameters)
{
global $context;
// do we have some API key?
if (!isset($context['obs_api_key'])) {
return array('code' => -32000, 'message' => 'Missing credentials to use OBS API');
}
// look for a call id
if (empty($parameters['call_id'])) {
return array('code' => -32602, 'message' => 'Invalid parameter "call_id"');
}
// data to be submitted to OBS
$data = array();
$data[] = 'id=' . urlencode($context['obs_api_key']);
$data[] = 'call_id=' . urlencode($parameters['call_id']);
// build the endpoint to invoke
$url = self::build_obs_link('call/releaseCall', $data);
// do release the call
if (!($response = http::proceed_natively($url))) {
return array('code' => -32603, 'message' => 'Unable to query the OBS API');
}
// ensure we receive correct xml
if (!($xml = simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA))) {
return array('code' => -32603, 'message' => 'Invalid response from OBS API');
}
// stop on error
if ($xml->status->status_code != 200) {
return array('code' => -32000, 'message' => 'Error: ' . $xml->status->status_code . ' ' . $xml->status->status_msg);
}
// look for call id
if (!($id = $xml->call_info->call_id)) {
return array('code' => -32603, 'message' => 'Invalid response from OBS API');
}
// provide id back to caller
return array('call_id' => (string) $id);
}
示例5: array
if (isset($context['opentok_api_url']) && $context['opentok_api_url']) {
$url = $context['opentok_api_url'];
} else {
$url = 'https://staging.tokbox.com/hl';
}
// link to create a session
$url .= '/session/create';
// authenticate through HTTP headers
$headers = array('X-TB-PARTNER-AUTH: ' . $context['opentok_api_key'] . ':' . $context['opentok_api_secret']);
// parameters of this session
$parameters = array();
$parameters['api_key'] = $context['opentok_api_key'];
$parameters['location'] = $_SERVER['REMOTE_ADDR'];
// $parameters['p2p.preference'] = 'enabled';
// get a new session id
if (!($response = http::proceed_natively($url, $headers, $parameters))) {
Logger::error(sprintf('OpenTok: %s', 'response is not valid XML'));
} elseif (!($xml = @simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA))) {
Logger::error(sprintf('OpenTok: %s', 'response is not valid XML'));
} elseif ($errors = $xml->xpath("//error")) {
if ($message = $errors[0]->xpath("//@message")) {
$message = (string) $message[0]['message'];
} else {
$message = 'unknown error';
}
Logger::error(sprintf('OpenTok: %s', $xml->error['code'] . ' ' . $xml->error->children()->getName() . ': ' . $message));
// no session id in the response
} elseif (!isset($xml->Session->session_id)) {
Logger::error(sprintf('OpenTok: %s', 'no session id has been provided'));
} else {
// save the pair meeting id - OpenTok id in a text file