本文整理汇总了PHP中common_valid_http_url函数的典型用法代码示例。如果您正苦于以下问题:PHP common_valid_http_url函数的具体用法?PHP common_valid_http_url怎么用?PHP common_valid_http_url使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了common_valid_http_url函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: prepare
/**
* For initializing members of the class.
*
* @param array $args misc. arguments
*
* @return boolean true
*/
function prepare($args)
{
parent::prepare($args);
if (!$this->isPost()) {
throw new ClientException(_('POST only'), 405);
}
$this->checkSessionToken();
$this->url = $this->trimmed('url');
if (empty($this->url)) {
throw new ClientException(_('URL is required.'), 400);
}
if (!common_valid_http_url($this->url)) {
throw new ClientException(_('Invalid URL.'), 400);
}
try {
// processNew will first try to fetch a locally stored File entry
$f = File::processNew($this->url);
} catch (ServerException $e) {
$f = null;
}
// How about now?
if ($f instanceof File) {
// FIXME: Use some File metadata Event instead
$this->oembed = File_oembed::getKV('file_id', $f->id);
if ($this->oembed instanceof File_oembed) {
$this->title = $this->oembed->title;
}
$this->thumbnail = File_thumbnail::getKV('file_id', $f->id);
}
return true;
}
示例2: onEndFindMentions
function onEndFindMentions(Profile $sender, $text, &$mentions)
{
$matches = array();
preg_match_all('/(?:^|\\s+)@([A-Za-z0-9_:\\-\\.\\/%]+)\\b/', $text, $atmatches, PREG_OFFSET_CAPTURE);
foreach ($atmatches[1] as $match) {
$url = $match[0];
if (!common_valid_http_url($url)) {
$url = 'http://' . $url;
}
if (common_valid_http_url($url)) {
$mentioned = Mention_url_profile::fromUrl($url);
$text = mb_strlen($mentioned->nickname) <= mb_strlen($match[0]) ? $mentioned->nickname : $match[0];
}
if ($mentioned instanceof Profile) {
$matches[$match[1]] = array('mentioned' => array($mentioned), 'type' => 'mention', 'text' => $text, 'position' => $match[1], 'length' => mb_strlen($match[0]), 'url' => $mentioned->profileurl);
}
}
foreach ($mentions as $i => $other) {
// If we share a common prefix with a local user, override it!
$pos = $other['position'];
if (isset($matches[$pos])) {
$mentions[$i] = $matches[$pos];
unset($matches[$pos]);
}
}
foreach ($matches as $mention) {
$mentions[] = $mention;
}
return true;
}
示例3: handle
function handle($args)
{
// Trigger short error responses; not a human-readable web page.
StatusNet::setApi(true);
// We're not a general oEmbed proxy service; limit to valid sessions.
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->clientError(_m('There was a problem with your session token. ' . 'Try again, please.'));
}
$format = $this->arg('format');
if ($format && $format != 'json') {
// TRANS: Client exception thrown when requesting a different format than JSON.
throw new ClientException(_m('Invalid format; only JSON supported.'));
}
$url = $this->arg('url');
if (!common_valid_http_url($url)) {
// TRANS: Client exception thrown when not providing a valid URL.
throw new ClientException(_m('Invalid URL.'));
}
$params = array();
if ($this->arg('maxwidth')) {
$params['maxwidth'] = $this->arg('maxwidth');
}
if ($this->arg('maxheight')) {
$params['maxheight'] = $this->arg('maxheight');
}
$data = oEmbedHelper::getObject($url, $params);
$this->init_document('json');
print json_encode($data);
}
示例4: validateFeedUrl
protected function validateFeedUrl($url)
{
if (common_valid_http_url($url)) {
return $url;
} else {
$this->clientError(_m("Invalid feed URL."));
}
}
示例5: validateFeedUrl
protected function validateFeedUrl($url)
{
if (common_valid_http_url($url)) {
return $url;
} else {
// TRANS: Client error displayed when entering an invalid URL for a feed.
// TRANS: %s is the invalid feed URL.
$this->clientError(sprintf(_m("Invalid feed URL: %s."), $url));
}
}
示例6: doPost
protected function doPost()
{
if (Event::handle('StartGroupSaveForm', array($this))) {
$nickname = Nickname::normalize($this->trimmed('newnickname'), true);
$fullname = $this->trimmed('fullname');
$homepage = $this->trimmed('homepage');
$description = $this->trimmed('description');
$location = $this->trimmed('location');
$private = $this->boolean('private');
$aliasstring = $this->trimmed('aliases');
if (!is_null($homepage) && strlen($homepage) > 0 && !common_valid_http_url($homepage)) {
// TRANS: Group create form validation error.
throw new ClientException(_('Homepage is not a valid URL.'));
} else {
if (!is_null($fullname) && mb_strlen($fullname) > 255) {
// TRANS: Group create form validation error.
throw new ClientException(_('Full name is too long (maximum 255 characters).'));
} else {
if (User_group::descriptionTooLong($description)) {
// TRANS: Group create form validation error.
// TRANS: %d is the maximum number of allowed characters.
throw new ClientException(sprintf(_m('Description is too long (maximum %d character).', 'Description is too long (maximum %d characters).', User_group::maxDescription()), User_group::maxDescription()));
} else {
if (!is_null($location) && mb_strlen($location) > 255) {
// TRANS: Group create form validation error.
throw new ClientException(_('Location is too long (maximum 255 characters).'));
}
}
}
}
if (!empty($aliasstring)) {
$aliases = array_map(array('Nickname', 'normalize'), array_unique(preg_split('/[\\s,]+/', $aliasstring)));
} else {
$aliases = array();
}
if (count($aliases) > common_config('group', 'maxaliases')) {
// TRANS: Group create form validation error.
// TRANS: %d is the maximum number of allowed aliases.
throw new ClientException(sprintf(_m('Too many aliases! Maximum %d allowed.', 'Too many aliases! Maximum %d allowed.', common_config('group', 'maxaliases')), common_config('group', 'maxaliases')));
}
if ($private) {
$force_scope = 1;
$join_policy = User_group::JOIN_POLICY_MODERATE;
} else {
$force_scope = 0;
$join_policy = User_group::JOIN_POLICY_OPEN;
}
// This is set up in parent->prepare and checked in self->prepare
assert(!is_null($this->scoped));
$group = User_group::register(array('nickname' => $nickname, 'fullname' => $fullname, 'homepage' => $homepage, 'description' => $description, 'location' => $location, 'aliases' => $aliases, 'userid' => $this->scoped->id, 'join_policy' => $join_policy, 'force_scope' => $force_scope, 'local' => true));
$this->group = $group;
Event::handle('EndGroupSaveForm', array($this));
common_redirect($group->homeUrl(), 303);
}
}
示例7: saveObjectFromActivity
protected function saveObjectFromActivity(Activity $act, Notice $stored, array $options = array())
{
assert($this->isMyActivity($act));
$stored->object_type = ActivityUtils::resolveUri($act->objects[0]->type);
if (common_valid_http_url($act->objects[0]->link)) {
$stored->url = $act->objects[0]->link;
}
// We don't have to do just about anything for a new, remote notice since the fields
// are handled in the main Notice::saveActivity function. Such as content, attachments,
// parent/conversation etc.
// By returning true here instead of something that evaluates
// to false, we show that we have processed everything properly.
return true;
}
示例8: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*/
protected function prepare(array $args = array())
{
parent::prepare($args);
if ($this->format !== 'json') {
$this->clientError('This method currently only serves JSON.', 415);
}
$this->url = urldecode($args['url']);
if (empty($this->url)) {
$this->clientError(_('No URL.'), 403);
}
if (!common_valid_http_url($this->url)) {
$this->clientError(_('Invalid URL.'), 403);
}
return true;
}
示例9: updateAvatar
/**
* Download and update given avatar image
*
* @param string $url
* @throws Exception in various failure cases
*/
public function updateAvatar($url)
{
if (!common_valid_http_url($url)) {
// TRANS: Server exception. %s is a URL.
throw new ServerException(sprintf(_m('Invalid avatar URL %s.'), $url));
}
if ($this->isGroup()) {
$self = $this->localGroup();
} else {
$self = $this->localProfile();
}
if (!$self) {
throw new ServerException(sprintf(_m('Tried to update avatar for unsaved remote profile %s.'), $this->uri));
}
// @fixme this should be better encapsulated
// ripped from oauthstore.php (for old OMB client)
$temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
try {
if (!copy($url, $temp_filename)) {
// TRANS: Server exception. %s is a URL.
throw new ServerException(sprintf(_m('Unable to fetch avatar from %s.'), $url));
}
if ($this->isGroup()) {
$id = $this->group_id;
} else {
$id = $this->profile_id;
}
// @fixme should we be using different ids?
$imagefile = new ImageFile($id, $temp_filename);
$filename = Avatar::filename($id, image_type_to_extension($imagefile->type), null, common_timestamp());
rename($temp_filename, Avatar::path($filename));
} catch (Exception $e) {
unlink($temp_filename);
throw $e;
}
// @fixme hardcoded chmod is lame, but seems to be necessary to
// keep from accidentally saving images from command-line (queues)
// that can't be read from web server, which causes hard-to-notice
// problems later on:
//
// http://status.net/open-source/issues/2663
chmod(Avatar::path($filename), 0644);
$self->setOriginal($filename);
$orig = clone $this;
$this->avatar = $url;
$this->update($orig);
}
示例10: save_notice
function save_notice(&$req, &$consumer, &$token)
{
$version = $req->get_parameter('omb_version');
if ($version != OMB_VERSION_01) {
$this->clientError(_('Unsupported OMB version'), 400);
return false;
}
# First, check to see
$listenee = $req->get_parameter('omb_listenee');
$remote_profile = Remote_profile::staticGet('uri', $listenee);
if (!$remote_profile) {
$this->clientError(_('Profile unknown'), 403);
return false;
}
$sub = Subscription::staticGet('token', $token->key);
if (!$sub) {
$this->clientError(_('No such subscription'), 403);
return false;
}
$content = $req->get_parameter('omb_notice_content');
$content_shortened = common_shorten_links($content);
if (mb_strlen($content_shortened) > 140) {
$this->clientError(_('Invalid notice content'), 400);
return false;
}
$notice_uri = $req->get_parameter('omb_notice');
if (!Validate::uri($notice_uri) && !common_valid_tag($notice_uri)) {
$this->clientError(_('Invalid notice uri'), 400);
return false;
}
$notice_url = $req->get_parameter('omb_notice_url');
if ($notice_url && !common_valid_http_url($notice_url)) {
$this->clientError(_('Invalid notice url'), 400);
return false;
}
$notice = Notice::staticGet('uri', $notice_uri);
if (!$notice) {
$notice = Notice::saveNew($remote_profile->id, $content, 'omb', false, null, $notice_uri);
if (is_string($notice)) {
common_server_serror($notice, 500);
return false;
}
common_broadcast_notice($notice, true);
}
return true;
}
示例11: tryRegister
/**
* Try to register a user
*
* Validates the input and tries to save a new user and profile
* record. On success, shows an instructions page.
*
* @return void
*/
function tryRegister()
{
if (Event::handle('StartRegistrationTry', array($this))) {
$token = $this->trimmed('token');
if (!$token || $token != common_session_token()) {
// TRANS: Client error displayed when the session token does not match or is not given.
$this->showForm(_('There was a problem with your session token. ' . 'Try again, please.'));
return;
}
$nickname = $this->trimmed('nickname');
$email = $this->trimmed('email');
$fullname = $this->trimmed('fullname');
$homepage = $this->trimmed('homepage');
$bio = $this->trimmed('bio');
$location = $this->trimmed('location');
// We don't trim these... whitespace is OK in a password!
$password = $this->arg('password');
$confirm = $this->arg('confirm');
// invitation code, if any
$code = $this->trimmed('code');
if ($code) {
$invite = Invitation::getKV($code);
}
if (common_config('site', 'inviteonly') && !($code && $invite)) {
// TRANS: Client error displayed when trying to register to an invite-only site without an invitation.
$this->clientError(_('Sorry, only invited people can register.'));
}
// Input scrubbing
try {
$nickname = Nickname::normalize($nickname, true);
} catch (NicknameException $e) {
$this->showForm($e->getMessage());
return;
}
$email = common_canonical_email($email);
if (!$this->boolean('license')) {
// TRANS: Form validation error displayed when trying to register without agreeing to the site license.
$this->showForm(_('You cannot register if you do not ' . 'agree to the license.'));
} else {
if ($email && !Validate::email($email, common_config('email', 'check_domain'))) {
// TRANS: Form validation error displayed when trying to register without a valid e-mail address.
$this->showForm(_('Not a valid email address.'));
} else {
if ($this->emailExists($email)) {
// TRANS: Form validation error displayed when trying to register with an already registered e-mail address.
$this->showForm(_('Email address already exists.'));
} else {
if (!is_null($homepage) && strlen($homepage) > 0 && !common_valid_http_url($homepage)) {
// TRANS: Form validation error displayed when trying to register with an invalid homepage URL.
$this->showForm(_('Homepage is not a valid URL.'));
} else {
if (!is_null($fullname) && mb_strlen($fullname) > 255) {
// TRANS: Form validation error displayed when trying to register with a too long full name.
$this->showForm(_('Full name is too long (maximum 255 characters).'));
} else {
if (Profile::bioTooLong($bio)) {
// TRANS: Form validation error on registration page when providing too long a bio text.
// TRANS: %d is the maximum number of characters for bio; used for plural.
$this->showForm(sprintf(_m('Bio is too long (maximum %d character).', 'Bio is too long (maximum %d characters).', Profile::maxBio()), Profile::maxBio()));
} else {
if (!is_null($location) && mb_strlen($location) > 255) {
// TRANS: Form validation error displayed when trying to register with a too long location.
$this->showForm(_('Location is too long (maximum 255 characters).'));
} else {
if (strlen($password) < 6) {
// TRANS: Form validation error displayed when trying to register with too short a password.
$this->showForm(_('Password must be 6 or more characters.'));
} else {
if ($password != $confirm) {
// TRANS: Form validation error displayed when trying to register with non-matching passwords.
$this->showForm(_('Passwords do not match.'));
} else {
try {
$user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email, 'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio, 'location' => $location, 'code' => $code));
// success!
if (!common_set_user($user)) {
// TRANS: Server error displayed when saving fails during user registration.
$this->serverError(_('Error setting user.'));
}
// this is a real login
common_real_login(true);
if ($this->boolean('rememberme')) {
common_debug('Adding rememberme cookie for ' . $nickname);
common_rememberme($user);
}
// Re-init language env in case it changed (not yet, but soon)
common_init_language();
Event::handle('EndRegistrationTry', array($this));
$this->showSuccess();
} catch (Exception $e) {
// TRANS: Form validation error displayed when trying to register with an invalid username or password.
$this->showForm($e->getMessage());
//.........这里部分代码省略.........
示例12: saveAvatar
/**
* Actually save the avatar we found locally.
*
* @param User $user
* @param string $url to avatar URL
* @todo merge wrapper funcs for this into common place for 1.0 core
*/
private function saveAvatar($user, $url)
{
if (!common_valid_http_url($url)) {
throw new ServerException(sprintf(_m("Invalid avatar URL %s."), $url));
}
// @fixme this should be better encapsulated
// ripped from OStatus via oauthstore.php (for old OMB client)
$temp_filename = tempnam(sys_get_temp_dir(), 'listener_avatar');
try {
if (!copy($url, $temp_filename)) {
throw new ServerException(sprintf(_m("Unable to fetch avatar from %s."), $url));
}
$profile = $user->getProfile();
$id = $profile->id;
// @fixme should we be using different ids?
$imagefile = new ImageFile($id, $temp_filename);
$filename = Avatar::filename($id, image_type_to_extension($imagefile->type), null, common_timestamp());
rename($temp_filename, Avatar::path($filename));
} catch (Exception $e) {
unlink($temp_filename);
throw $e;
}
$profile->setOriginal($filename);
}
示例13: oid_authenticate
function oid_authenticate($openid_url, $returnto, $immediate = false)
{
if (!common_valid_http_url($openid_url)) {
throw new ClientException(_m('No valid URL provided for OpenID.'));
}
$consumer = oid_consumer();
if (!$consumer) {
// TRANS: OpenID plugin server error.
throw new ServerException(_m('Cannot instantiate OpenID consumer object.'));
}
common_ensure_session();
$auth_request = $consumer->begin($openid_url);
// Handle failure status return values.
if (!$auth_request) {
common_log(LOG_ERR, __METHOD__ . ": mystery fail contacting {$openid_url}");
// TRANS: OpenID plugin message. Given when an OpenID is not valid.
throw new ServerException(_m('Not a valid OpenID.'));
} else {
if (Auth_OpenID::isFailure($auth_request)) {
common_log(LOG_ERR, __METHOD__ . ": OpenID fail to {$openid_url}: {$auth_request->message}");
// TRANS: OpenID plugin server error. Given when the OpenID authentication request fails.
// TRANS: %s is the failure message.
throw new ServerException(sprintf(_m('OpenID failure: %s.'), $auth_request->message));
}
}
$sreg_request = Auth_OpenID_SRegRequest::build(array(), array('nickname', 'email', 'fullname', 'language', 'timezone', 'postcode', 'country'));
if ($sreg_request) {
$auth_request->addExtension($sreg_request);
}
$requiredTeam = common_config('openid', 'required_team');
if ($requiredTeam) {
// LaunchPad OpenID extension
$team_request = new Auth_OpenID_TeamsRequest(array($requiredTeam));
if ($team_request) {
$auth_request->addExtension($team_request);
}
}
$trust_root = common_root_url(true);
$process_url = common_local_url($returnto);
// Net::OpenID::Server as used on LiveJournal appears to incorrectly
// reject POST requests for data submissions that OpenID 1.1 specs
// as GET, although 2.0 allows them:
// https://rt.cpan.org/Public/Bug/Display.html?id=42202
//
// Our OpenID libraries would have switched in the redirect automatically
// if it were detecting 1.1 compatibility mode, however the server is
// advertising itself as 2.0-compatible, so we got switched to the POST.
//
// Since the GET should always work anyway, we'll just take out the
// autosubmitter for now.
//
//if ($auth_request->shouldSendRedirect()) {
$redirect_url = $auth_request->redirectURL($trust_root, $process_url, $immediate);
if (Auth_OpenID::isFailure($redirect_url)) {
// TRANS: OpenID plugin server error. Given when the OpenID authentication request cannot be redirected.
// TRANS: %s is the failure message.
throw new ServerException(sprintf(_m('Could not redirect to server: %s.'), $redirect_url->message));
}
common_redirect($redirect_url, 303);
/*
} else {
// Generate form markup and render it.
$form_id = 'openid_message';
$form_html = $auth_request->formMarkup($trust_root, $process_url,
$immediate, array('id' => $form_id));
// XXX: This is cheap, but things choke if we don't escape ampersands
// in the HTML attributes
$form_html = preg_replace('/&/', '&', $form_html);
// Display an error if the form markup couldn't be generated;
// otherwise, render the HTML.
if (Auth_OpenID::isFailure($form_html)) {
// TRANS: OpenID plugin server error if the form markup could not be generated.
// TRANS: %s is the failure message.
common_server_error(sprintf(_m('Could not create OpenID form: %s'), $form_html->message));
} else {
$action = new AutosubmitAction(); // see below
$action->form_html = $form_html;
$action->form_id = $form_id;
$action->prepare(array('action' => 'autosubmit'));
$action->handle(array('action' => 'autosubmit'));
}
}
*/
}
示例14: handle
/**
* Handle the request
*
* @param array $args $_REQUEST data (unused)
*
* @return void
*/
protected function handle()
{
parent::handle();
$nickname = $this->trimmed('nickname');
$email = $this->trimmed('email');
$fullname = $this->trimmed('fullname');
$homepage = $this->trimmed('homepage');
$bio = $this->trimmed('bio');
$location = $this->trimmed('location');
// We don't trim these... whitespace is OK in a password!
$password = $this->arg('password');
$confirm = $this->arg('confirm');
if (empty($this->code)) {
common_ensure_session();
if (array_key_exists('invitecode', $_SESSION)) {
$this->code = $_SESSION['invitecode'];
}
}
if (common_config('site', 'inviteonly') && empty($this->code)) {
// TRANS: Client error displayed when trying to register to an invite-only site without an invitation.
$this->clientError(_('Sorry, only invited people can register.'), 401);
}
if (!empty($this->code)) {
$this->invite = Invitation::getKV('code', $this->code);
if (empty($this->invite)) {
// TRANS: Client error displayed when trying to register to an invite-only site without a valid invitation.
$this->clientError(_('Sorry, invalid invitation code.'), 401);
}
// Store this in case we need it
common_ensure_session();
$_SESSION['invitecode'] = $this->code;
}
// Input scrubbing
try {
$nickname = Nickname::normalize($nickname, true);
} catch (NicknameException $e) {
// clientError handles Api exceptions with various formats and stuff
$this->clientError($e->getMessage(), $e->getCode());
}
$email = common_canonical_email($email);
if ($email && !Validate::email($email, common_config('email', 'check_domain'))) {
// TRANS: Form validation error displayed when trying to register without a valid e-mail address.
$this->clientError(_('Not a valid email address.'), 400);
} else {
if ($this->emailExists($email)) {
// TRANS: Form validation error displayed when trying to register with an already registered e-mail address.
$this->clientError(_('Email address already exists.'), 400);
} else {
if (!is_null($homepage) && strlen($homepage) > 0 && !common_valid_http_url($homepage)) {
// TRANS: Form validation error displayed when trying to register with an invalid homepage URL.
$this->clientError(_('Homepage is not a valid URL.'), 400);
} else {
if (!is_null($fullname) && mb_strlen($fullname) > 255) {
// TRANS: Form validation error displayed when trying to register with a too long full name.
$this->clientError(_('Full name is too long (maximum 255 characters).'), 400);
} else {
if (Profile::bioTooLong($bio)) {
// TRANS: Form validation error on registration page when providing too long a bio text.
// TRANS: %d is the maximum number of characters for bio; used for plural.
$this->clientError(sprintf(_m('Bio is too long (maximum %d character).', 'Bio is too long (maximum %d characters).', Profile::maxBio()), Profile::maxBio()), 400);
} else {
if (!is_null($location) && mb_strlen($location) > 255) {
// TRANS: Form validation error displayed when trying to register with a too long location.
$this->clientError(_('Location is too long (maximum 255 characters).'), 400);
} else {
if (strlen($password) < 6) {
// TRANS: Form validation error displayed when trying to register with too short a password.
$this->clientError(_('Password must be 6 or more characters.'), 400);
} else {
if ($password != $confirm) {
// TRANS: Form validation error displayed when trying to register with non-matching passwords.
$this->clientError(_('Passwords do not match.'), 400);
} else {
// annoy spammers
sleep(7);
try {
$user = User::register(array('nickname' => $nickname, 'password' => $password, 'email' => $email, 'fullname' => $fullname, 'homepage' => $homepage, 'bio' => $bio, 'location' => $location, 'code' => $this->code));
Event::handle('EndRegistrationTry', array($this));
$this->initDocument('json');
$this->showJsonObjects($this->twitterUserArray($user->getProfile()));
$this->endDocument('json');
} catch (Exception $e) {
$this->clientError($e->getMessage(), 400);
}
}
}
}
}
}
}
}
}
}
示例15: remoteSubscription
function remoteSubscription()
{
if (!$this->nickname) {
$this->showForm(_('No such user.'));
return;
}
$user = User::staticGet('nickname', $this->nickname);
$this->profile_url = $this->trimmed('profile_url');
if (!$this->profile_url) {
$this->showForm(_('No such user.'));
return;
}
if (!common_valid_http_url($this->profile_url)) {
$this->showForm(_('Invalid profile URL (bad format)'));
return;
}
try {
$service = new OMB_Service_Consumer($this->profile_url, common_root_url(), omb_oauth_datastore());
} catch (OMB_InvalidYadisException $e) {
$this->showForm(_('Not a valid profile URL (no YADIS document or ' . 'invalid XRDS defined).'));
return;
}
if ($service->getServiceURI(OAUTH_ENDPOINT_REQUEST) == common_local_url('requesttoken') || User::staticGet('uri', $service->getRemoteUserURI())) {
$this->showForm(_('That’s a local profile! Login to subscribe.'));
return;
}
try {
$service->requestToken();
} catch (OMB_RemoteServiceException $e) {
$this->showForm(_('Couldn’t get a request token.'));
return;
}
/* Create an OMB_Profile from $user. */
$profile = $user->getProfile();
if (!$profile) {
common_log_db_error($user, 'SELECT', __FILE__);
$this->serverError(_('User without matching profile.'));
return;
}
$target_url = $service->requestAuthorization(profile_to_omb_profile($user->uri, $profile), common_local_url('finishremotesubscribe'));
common_ensure_session();
$_SESSION['oauth_authorization_request'] = serialize($service);
/* Redirect to the remote service for authorization. */
common_redirect($target_url, 303);
}