本文整理汇总了PHP中ApiAuthAction类的典型用法代码示例。如果您正苦于以下问题:PHP ApiAuthAction类的具体用法?PHP ApiAuthAction怎么用?PHP ApiAuthAction使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ApiAuthAction类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: handle
function handle($args)
{
parent::handle($args);
$auth = new ApiAuthAction();
$auth->checkBasicAuthUser(false);
$this->user = $auth->auth_user;
$type = $this->trimmed('type');
$hotResult = null;
switch ($type) {
case 'tags':
$hotResult = $this->getHotTags();
break;
case 'users':
$hotResult = $this->getHotUsers();
break;
default:
$this->clientError(_('invalid type'));
return;
break;
}
$this->initDocument('json');
$this->showJsonObjects($hotResult);
$this->endDocument('json');
}
开发者ID:jianoll,项目名称:SpeakEnglish_Server,代码行数:24,代码来源:apisuggestionshot.php
示例2: 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
示例3: 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
示例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 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
示例5: 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
示例6: 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
示例7: 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
示例8: prepare
/**
* For initializing members of the class.
*
* @param array $argarray misc. arguments
*
* @return boolean true
*/
function prepare($argarray)
{
parent::prepare($argarray);
$convId = $this->trimmed('id');
if (empty($convId)) {
// TRANS: Client exception thrown when no conversation ID is given.
throw new ClientException(_('No conversation ID.'));
}
$this->conversation = Conversation::staticGet('id', $convId);
if (empty($this->conversation)) {
// TRANS: Client exception thrown when referring to a non-existing conversation ID (%d).
$this->clientError(_('No conversation ID found'), 404);
return false;
}
$profile = Profile::current();
$stream = new ConversationNoticeStream($convId, $profile);
$notice = $stream->getNotices(($this->page - 1) * $this->count, $this->count, $this->since_id, $this->max_id);
$this->notices = $notice->fetchAll();
$originalConversation = new Notice();
$originalConversation->whereAdd('conversation=' . $convId);
$originalConversation->limit(1);
$originalConversation->orderBy('created');
$originalConversation->find();
if ($originalConversation->fetch()) {
$this->originalNotice = $originalConversation;
}
return true;
}
开发者ID:jianoll,项目名称:SpeakEnglish_Server,代码行数:35,代码来源:apiconversation.php
示例9: 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
示例10: 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
示例11: 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
示例12: 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
示例13: 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
示例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: prepare
/**
* Take arguments for running
*
* @param array $args $_REQUEST args
*
* @return boolean success flag
*
*/
function prepare($args)
{
parent::prepare($args);
// TRANS: Server error displayed calling unimplemented API method for 'retweeted by me'.
$this->serverError(_('Unimplemented.'), 503);
return false;
}
开发者ID:microcosmx,项目名称:experiments,代码行数:15,代码来源:apitimelineretweetedbyme.php
示例16: 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
示例17: 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
示例18: 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
示例19: handle
/**
* Handle the request
*
* See which request params have been set, and update the profile
*
* @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->user)) {
$this->clientError(_('No such user.'), 404, $this->format);
return;
}
$profile = $this->user->getProfile();
if (empty($profile)) {
$this->clientError(_('User has no profile.'));
return;
}
$original = clone $profile;
if (!empty($this->name)) {
$profile->fullname = $this->name;
}
if (!empty($this->url)) {
$profile->homepage = $this->url;
}
if (!empty($this->description)) {
$profile->bio = $this->description;
}
if (!empty($this->location)) {
$profile->location = $this->location;
$loc = Location::fromName($location);
if (!empty($loc)) {
$profile->lat = $loc->lat;
$profile->lon = $loc->lon;
$profile->location_id = $loc->location_id;
$profile->location_ns = $loc->location_ns;
}
}
$result = $profile->update($original);
if (!$result) {
common_log_db_error($profile, 'UPDATE', __FILE__);
$this->serverError(_('Could not save profile.'));
return;
}
common_broadcast_profile($profile);
$twitter_user = $this->twitterUserArray($profile, true);
if ($this->format == 'xml') {
$this->initDocument('xml');
$this->showTwitterXmlUser($twitter_user);
$this->endDocument('xml');
} elseif ($this->format == 'json') {
$this->initDocument('json');
$this->showJsonObjects($twitter_user);
$this->endDocument('json');
}
}
开发者ID:sukhjindersingh,项目名称:PHInest-Solutions,代码行数:67,代码来源:apiaccountupdateprofile.php
示例20: handle
/**
* Handle the request
*
* @param array $args $_REQUEST data (unused)
*
* @return void
*/
protected function handle()
{
parent::handle();
// save the new bookmarks
$saved = Profile_prefs::setData($this->scoped, 'qvitter', 'bookmarks', $this->bookmarks);
$this->initDocument('json');
$this->showJsonObjects($saved);
$this->endDocument('json');
}
开发者ID:GreenLunar,项目名称:qvitter,代码行数:16,代码来源:apiqvitterupdatebookmarks.php
注:本文中的ApiAuthAction类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论