当前位置: 首页>>代码示例>>PHP>>正文


PHP ApiAuthAction::handle方法代码示例

本文整理汇总了PHP中ApiAuthAction::handle方法的典型用法代码示例。如果您正苦于以下问题:PHP ApiAuthAction::handle方法的具体用法?PHP ApiAuthAction::handle怎么用?PHP ApiAuthAction::handle使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ApiAuthAction的用法示例。


在下文中一共展示了ApiAuthAction::handle方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: handle

 /**
  * Handle the request
  *
  * Get favs and return them as json object
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     $fave = new Fave();
     $fave->selectAdd();
     $fave->selectAdd('user_id');
     $fave->notice_id = $this->original->id;
     $fave->orderBy('modified');
     if (!is_null($this->cnt)) {
         $fave->limit(0, $this->cnt);
     }
     $ids = $fave->fetchAll('user_id');
     // get nickname and profile image
     $ids_with_profile_data = array();
     $i = 0;
     foreach ($ids as $id) {
         $profile = Profile::getKV('id', $id);
         $ids_with_profile_data[$i]['user_id'] = $id;
         $ids_with_profile_data[$i]['nickname'] = $profile->nickname;
         $ids_with_profile_data[$i]['fullname'] = $profile->fullname;
         $ids_with_profile_data[$i]['profileurl'] = $profile->profileurl;
         $profile = new Profile();
         $profile->id = $id;
         $avatarurl = $profile->avatarUrl(24);
         $ids_with_profile_data[$i]['avatarurl'] = $avatarurl;
         $i++;
     }
     $this->initDocument('json');
     $this->showJsonObjects($ids_with_profile_data);
     $this->endDocument('json');
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:40,代码来源:apistatusesfavs.php

示例2: handle

 /**
  * Handle the request
  *
  * Grab the file from the 'media' param, then store, and shorten
  *
  * @todo Upload throttle!
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     // Workaround for PHP returning empty $_POST and $_FILES when POST
     // length > post_max_size in php.ini
     if (empty($_FILES) && empty($_POST) && $_SERVER['CONTENT_LENGTH'] > 0) {
         $msg = _('The server was unable to handle that much POST ' . 'data (%s bytes) due to its current configuration.');
         $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
         return;
     }
     $upload = null;
     try {
         $upload = MediaFile::fromUpload('media', $this->auth_user);
     } catch (ClientException $ce) {
         $this->clientError($ce->getMessage());
         return;
     }
     if (isset($upload)) {
         $this->showResponse($upload);
     } else {
         $this->clientError('Upload failed.');
         return;
     }
 }
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:39,代码来源:apimediaupload.php

示例3: handle

 /**
  * Handle the request
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     $this->initDocument('json');
     $this->showJsonObjects('hello');
     $this->endDocument('json');
 }
开发者ID:GreenLunar,项目名称:qvitter,代码行数:14,代码来源:apiqvitterhello.php

示例4: handle

 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     if (!in_array($this->format, array('xml', 'json'))) {
         $this->clientError(_('API method not found.'), 404, $this->format);
         return;
     }
     if (empty($this->other)) {
         $this->clientError(_('Could not unfollow user: User not found.'), 403, $this->format);
         return;
     }
     // Don't allow unsubscribing from yourself!
     if ($this->user->id == $this->other->id) {
         $this->clientError(_("You cannot unfollow yourself."), 403, $this->format);
         return;
     }
     // throws an exception on error
     Subscription::cancel($this->user->getProfile(), $this->other);
     $this->initDocument($this->format);
     $this->showProfile($this->other, $this->format);
     $this->endDocument($this->format);
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:35,代码来源:apifriendshipsdestroy.php

示例5: handle

 /**
  * Handle the request
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     $user = common_current_user();
     $profile = $user->getProfile();
     // what to toggle
     if (QvitterPlugin::settings('enabledbydefault')) {
         $toggle = 'disable_qvitter';
     } else {
         $toggle = 'enable_qvitter';
     }
     // new value
     $state = Profile_prefs::getConfigData($profile, 'qvitter', $toggle);
     if ($state == 1) {
         $new_state = 0;
     } else {
         $new_state = 1;
     }
     try {
         $pref_saved = Profile_prefs::setData($profile, 'qvitter', $toggle, $new_state);
         $result['success'] = true;
     } catch (ServerException $e) {
         $result['success'] = false;
         $result['error'] = $e;
     }
     if (!$pref_saved) {
         $result['success'] = false;
         $result['error'] = 'Probably couldn\'t get topic from pref table';
     }
     $this->initDocument('json');
     $this->showJsonObjects($result);
     $this->endDocument('json');
 }
开发者ID:bashrc,项目名称:gnusocial-qvitter-debian,代码行数:40,代码来源:apitoggleqvitter.php

示例6: handle

 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     if (!in_array($this->format, array('xml', 'json'))) {
         $this->clientError(_('API method not found.'), 404, $this->format);
         return;
     }
     if (empty($this->other)) {
         $this->clientError(_('Could not follow user: User not found.'), 403, $this->format);
         return;
     }
     if ($this->user->isSubscribed($this->other)) {
         $errmsg = sprintf(_('Could not follow user: %s is already on your list.'), $this->other->nickname);
         $this->clientError($errmsg, 403, $this->format);
         return;
     }
     $result = subs_subscribe_to($this->user, $this->other);
     if (is_string($result)) {
         $this->clientError($result, 403, $this->format);
         return;
     }
     $this->initDocument($this->format);
     $this->showProfile($this->other, $this->format);
     $this->endDocument($this->format);
 }
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:38,代码来源:apifriendshipscreate.php

示例7: handle

 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     if (!in_array($this->format, array('xml', 'json'))) {
         $this->clientError(_('API method not found.'), 404, $this->format);
         return;
     }
     if (empty($this->notice)) {
         $this->clientError(_('No status found with that ID.'), 404, $this->format);
         return;
     }
     $fave = new Fave();
     $fave->user_id = $this->user->id;
     $fave->notice_id = $this->notice->id;
     if (!$fave->find(true)) {
         $this->clientError(_('That status is not a favorite.'), 403, $this->favorite);
         return;
     }
     $result = $fave->delete();
     if (!$result) {
         common_log_db_error($fave, 'DELETE', __FILE__);
         $this->clientError(_('Could not delete favorite.'), 404, $this->format);
         return;
     }
     $this->user->blowFavesCache();
     if ($this->format == 'xml') {
         $this->showSingleXmlStatus($this->notice);
     } elseif ($this->format == 'json') {
         $this->show_single_json_status($this->notice);
     }
 }
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:44,代码来源:apifavoritedestroy.php

示例8: handle

 /**
  * Handle the request
  *
  * Save the new message
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     if (empty($this->user) || empty($this->other)) {
         // TRANS: Client error displayed when trying to block a non-existing user or a user from another site.
         $this->clientError(_('No such user.'), 404);
     }
     // Don't allow blocking yourself!
     if ($this->user->id == $this->other->id) {
         // TRANS: Client error displayed when users try to block themselves.
         $this->clientError(_("You cannot block yourself!"), 403);
     }
     if (!$this->user->hasBlocked($this->other)) {
         if (Event::handle('StartBlockProfile', array($this->user, $this->other))) {
             $result = $this->user->block($this->other);
             if ($result) {
                 Event::handle('EndBlockProfile', array($this->user, $this->other));
             }
         }
     }
     if ($this->user->hasBlocked($this->other)) {
         $this->initDocument($this->format);
         $this->showProfile($this->other, $this->format);
         $this->endDocument($this->format);
     } else {
         // TRANS: Server error displayed when blocking a user has failed.
         $this->serverError(_('Block user failed.'), 500);
     }
 }
开发者ID:bashrc,项目名称:gnusocial-debian,代码行数:38,代码来源:apiblockcreate.php

示例9: handle

 /**
  * Handle the request
  *
  * Save the new message
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     if (empty($this->user) || empty($this->other)) {
         $this->clientError(_('No such user.'), 404, $this->format);
         return;
     }
     // Don't allow blocking yourself!
     if ($this->user->id == $this->other->id) {
         $this->clientError(_("You cannot block yourself!"), 403, $this->format);
         return;
     }
     if (!$this->user->hasBlocked($this->other)) {
         if (Event::handle('StartBlockProfile', array($this->user, $this->other))) {
             $result = $this->user->block($this->other);
             if ($result) {
                 Event::handle('EndBlockProfile', array($this->user, $this->other));
             }
         }
     }
     if ($this->user->hasBlocked($this->other)) {
         $this->initDocument($this->format);
         $this->showProfile($this->other, $this->format);
         $this->endDocument($this->format);
     } else {
         $this->serverError(_('Block user failed.'), 500, $this->format);
     }
 }
开发者ID:Br3nda,项目名称:StatusNet,代码行数:41,代码来源:apiblockcreate.php

示例10: handle

 /**
  * Handle the request
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     $profile = $this->user->getProfile();
     $base64img = $this->img;
     if (stristr($base64img, 'image/jpeg')) {
         $base64img_mime = 'image/jpeg';
     } elseif (stristr($base64img, 'image/png')) {
         // should convert to jpg here!!
         $base64img_mime = 'image/png';
     }
     $base64img = str_replace('data:image/jpeg;base64,', '', $base64img);
     $base64img = str_replace('data:image/png;base64,', '', $base64img);
     $base64img = str_replace(' ', '+', $base64img);
     $base64img_hash = md5($base64img);
     $base64img = base64_decode($base64img);
     $base64img_basename = basename('bg');
     $base64img_filename = File::filename($profile, $base64img_basename, $base64img_mime);
     $base64img_path = File::path($base64img_filename);
     $base64img_success = file_put_contents($base64img_path, $base64img);
     $base64img_mimetype = MediaFile::getUploadedMimeType($base64img_path, $base64img_filename);
     $mediafile = new MediaFile($profile, $base64img_filename, $base64img_mimetype);
     $imagefile = new ImageFile($mediafile->fileRecord->id, File::path($mediafile->filename));
     $imagefile->resizeTo(File::path($mediafile->filename), array('width' => 1280, 'height' => 1280, 'x' => $this->cropX, 'y' => $this->cropY, 'w' => $this->cropW, 'h' => $this->cropH));
     $result['url'] = File::url($mediafile->filename);
     Profile_prefs::setData($profile, 'qvitter', 'background_image', $result['url']);
     $this->initDocument('json');
     $this->showJsonObjects($result);
     $this->endDocument('json');
 }
开发者ID:GreenLunar,项目名称:qvitter,代码行数:35,代码来源:apiupdatebackgroundimage.php

示例11: handle

 /**
  * Handle the request
  *
  * Save the new message
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     if (empty($this->user) || empty($this->other)) {
         $this->clientError(_('No such user.'), 404, $this->format);
         return;
     }
     if ($this->user->hasBlocked($this->other)) {
         if (Event::handle('StartUnblockProfile', array($this->user, $this->other))) {
             $result = $this->user->unblock($this->other);
             if ($result) {
                 Event::handle('EndUnblockProfile', array($this->user, $this->other));
             }
         }
     }
     if (!$this->user->hasBlocked($this->other)) {
         $this->initDocument($this->format);
         $this->showProfile($this->other, $this->format);
         $this->endDocument($this->format);
     } else {
         // TRANS: Server error displayed when unblocking a user has failed.
         $this->serverError(_('Unblock user failed.'));
     }
 }
开发者ID:ronhuang,项目名称:statusnet,代码行数:37,代码来源:apiblockdestroy.php

示例12: handle

 /**
  * Handle the request
  *
  * show a timeline of the user's repeated notices
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     $offset = ($this->page - 1) * $this->cnt;
     $limit = $this->cnt;
     $strm = $this->auth_user->repeatedToMe($offset, $limit, $this->since_id, $this->max_id);
     switch ($this->format) {
         case 'xml':
             $this->showXmlTimeline($strm);
             break;
         case 'json':
             $this->showJsonTimeline($strm);
             break;
         case 'atom':
             $profile = $this->auth_user->getProfile();
             // TRANS: Title for Atom feed "repeated to me". %s is the user nickname.
             $title = sprintf(_("Repeated to %s"), $this->auth_user->nickname);
             $taguribase = TagURI::base();
             $id = "tag:{$taguribase}:RepeatedToMe:" . $this->auth_user->id;
             $link = common_local_url('all', array('nickname' => $this->auth_user->nickname));
             $this->showAtomTimeline($strm, $title, $id, $link);
             break;
         default:
             // TRANS: Client error displayed when trying to handle an unknown API method.
             $this->clientError(_('API method not found.'), $code = 404);
             break;
     }
 }
开发者ID:stevertiqo,项目名称:StatusNet,代码行数:37,代码来源:apitimelineretweetedtome.php

示例13: handle

 /**
  * Handle the request
  *
  * Grab the file from the 'media' param, then store, and shorten
  *
  * @todo Upload throttle!
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     // Workaround for PHP returning empty $_POST and $_FILES when POST
     // length > post_max_size in php.ini
     if (empty($_FILES) && empty($_POST) && $_SERVER['CONTENT_LENGTH'] > 0) {
         // TRANS: Client error displayed when the number of bytes in a POST request exceeds a limit.
         // TRANS: %s is the number of bytes of the CONTENT_LENGTH.
         $msg = _m('The server was unable to handle that much POST data (%s byte) due to its current configuration.', 'The server was unable to handle that much POST data (%s bytes) due to its current configuration.', intval($_SERVER['CONTENT_LENGTH']));
         $this->clientError(sprintf($msg, $_SERVER['CONTENT_LENGTH']));
         return;
     }
     $upload = null;
     try {
         $upload = MediaFile::fromUpload('media', $this->auth_user);
     } catch (Exception $e) {
         $this->clientError($e->getMessage(), $e->getCode());
         return;
     }
     if (isset($upload)) {
         $this->showResponse($upload);
     } else {
         $this->clientError(_('Upload failed.'));
         return;
     }
 }
开发者ID:ronhuang,项目名称:statusnet,代码行数:41,代码来源:apimediaupload.php

示例14: handle

 /**
  * Handle the request
  *
  * Check the format and show the user info
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 function handle($args)
 {
     parent::handle($args);
     if ($_SERVER['REQUEST_METHOD'] != 'POST') {
         $this->clientError(_('This method requires a POST.'), 400, $this->format);
         return;
     }
     if (!in_array($this->format, array('xml', 'json'))) {
         $this->clientError(_('API method not found.'), 404, $this->format);
         return;
     }
     if (empty($this->notice)) {
         $this->clientError(_('No status found with that ID.'), 404, $this->format);
         return;
     }
     // Note: Twitter lets you fave things repeatedly via API.
     if ($this->user->hasFave($this->notice)) {
         $this->clientError(_('This status is already a favorite.'), 403, $this->format);
         return;
     }
     $fave = Fave::addNew($this->user->getProfile(), $this->notice);
     if (empty($fave)) {
         $this->clientError(_('Could not create favorite.'), 403, $this->format);
         return;
     }
     $this->notify($fave, $this->notice, $this->user);
     $this->user->blowFavesCache();
     if ($this->format == 'xml') {
         $this->showSingleXmlStatus($this->notice);
     } elseif ($this->format == 'json') {
         $this->show_single_json_status($this->notice);
     }
 }
开发者ID:Grasia,项目名称:bolotweet,代码行数:42,代码来源:apifavoritecreate.php

示例15: handle

 /**
  * Handle the request
  *
  * @param array $args $_REQUEST data (unused)
  *
  * @return void
  */
 protected function handle()
 {
     parent::handle();
     $json_obects = array();
     $this->initDocument('json');
     $this->showJsonObjects($json_obects);
     $this->endDocument('json');
 }
开发者ID:bashrc,项目名称:gnusocial-qvitter-debian,代码行数:15,代码来源:apitrendsplace.php


注:本文中的ApiAuthAction::handle方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。