本文整理汇总了PHP中okapi\Okapi::get_allowed_base_urls方法的典型用法代码示例。如果您正苦于以下问题:PHP Okapi::get_allowed_base_urls方法的具体用法?PHP Okapi::get_allowed_base_urls怎么用?PHP Okapi::get_allowed_base_urls使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类okapi\Okapi
的用法示例。
在下文中一共展示了Okapi::get_allowed_base_urls方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: call
public static function call(OkapiRequest $request)
{
$result = array();
$result['site_url'] = Settings::get('SITE_URL');
$result['okapi_base_url'] = Okapi::get_recommended_base_url();
$result['okapi_base_urls'] = Okapi::get_allowed_base_urls();
$result['site_name'] = Okapi::get_normalized_site_name();
$result['okapi_version_number'] = Okapi::$version_number;
$result['okapi_revision'] = Okapi::$version_number;
/* Important for backward-compatibility! */
$result['okapi_git_revision'] = Okapi::$git_revision;
$result['registration_url'] = Settings::get('REGISTRATION_URL');
$result['mobile_registration_url'] = Settings::get('MOBILE_REGISTRATION_URL');
$result['image_max_upload_size'] = Settings::get('IMAGE_MAX_UPLOAD_SIZE');
$result['image_rcmd_max_pixels'] = Settings::get('IMAGE_MAX_PIXEL_COUNT');
return Okapi::formatted_response($request, $result);
}
示例2: init_request
private function init_request()
{
$this->request = OAuthRequest::from_request();
/* Verify if the request was issued with proper HTTP method. */
if (!in_array($this->request->get_normalized_http_method(), array('GET', 'POST'))) {
throw new BadRequest("Use GET and POST methods only.");
}
/* Verify if the request was issued with proper okapi_base_url. */
$url = $this->request->get_normalized_http_url();
$allowed = false;
foreach (Okapi::get_allowed_base_urls() as $allowed_prefix) {
if (strpos($url, $allowed_prefix) === 0) {
$allowed = true;
break;
}
}
if (!$allowed) {
throw new BadRequest("Unrecognized base URL prefix! See `okapi_base_urls` field " . "in the `services/apisrv/installation` method. (Recommended " . "base URL to use is '" . Okapi::get_recommended_base_url() . "'.)");
}
}