0

我正在尝试制作一个简单的 android 应用程序,该应用程序可以从社交引擎网站读取实时信息,我该如何执行一些操作:

  • 验证用户
  • 阅读通知
  • 阅读信息
  • 显示更新

有没有我可以使用的特殊 API

抱歉,如果问题不清楚

4

5 回答 5

3

所有活动提要数据都可以在您的数据库中的 engine4_activity* 表中找到。恐怕我们的支持人员目前没有任何可以共享的图表或文档。我们的员工通常不会提供定制帮助,因为这超出了我们的支持服务范围 (http://support.socialengine.com/questions/152/SocialEngine-Requirements)。我将简要介绍如何使用授权和活动,但是需要通过查看 SocialEngine 的代码来推断出更详细的信息。请注意,虽然我们不为 SocialEngine 编译文档,但我们的开发人员在我们的代码中使用了 PHPDocumentor 样式语法,您可以使用像 Neatbeans (http://netbeans.org/) 这样的 IDE 来快速访问该信息。

授权

SocialEngine 有一些控制器动作助手类,用于在动作控制器中进行查询授权:

  • application/modules/Authorization/Controller/Action/Helper/RequireAuth.php
  • 应用程序/模块/Core/Controller/Action/Helper/RequireAbstract.php
  • 应用程序/模块/Core/Controller/Action/Helper/RequireAdmin.php
  • 应用程序/模块/Core/Controller/Action/Helper/RequireSubject.php
  • 应用程序/模块/Core/Controller/Action/Helper/RequireUser.php

在大多数情况下,您唯一关心的是这些:

  • application/modules/Authorization/Controller/Action/Helper/RequireAuth.php
  • 应用程序/模块/Core/Controller/Action/Helper/RequireSubject.php
  • 应用程序/模块/Core/Controller/Action/Helper/RequireUser.php

可以在 Album_AlbumController 类中找到如何使用这些帮助程序的一个很好的示例:application/modules/Album/controllers/AlbumController.php

public function init()
{
if( !$this->_helper->requireAuth()->setAuthParams('album', null, 'view')->isValid() ) return;

if( 0 !== ($photo_id = (int) $this->_getParam('photo_id')) &&
null !== ($photo = Engine_Api::_()->getItem('album_photo', $photo_id)) )
{
Engine_Api::_()->core()->setSubject($photo);
}

else if( 0 !== ($album_id = (int) $this->_getParam('album_id')) &&
null !== ($album = Engine_Api::_()->getItem('album', $album_id)) )
{
Engine_Api::_()->core()->setSubject($album);
}
}

public function editAction()
{
if( !$this->_helper->requireUser()->isValid() ) return;
if( !$this->_helper->requireSubject('album')->isValid() ) return;
if( !$this->_helper->requireAuth()->setAuthParams(null, null, 'edit')->isValid() ) return;

init 函数中的代码简单地设置访问页面的要求,然后在 editAction 函数中对授权数据进行检查。requireSubject 和 requireUser 助手非常简单:

  1. requireSubject 期望页面的主题被设置,在上面的例子中是在 init 函数中完成的
  2. requireUser 检查查看者是否是登录用户

requireAuth 帮助器不太直接。为简洁起见,我将省略大部分抽象的内部工作。最后,helper 指向 Authorization_Api_Core::isAllowed 函数:application/modules/Authorization/Core/Api.php

/**
* Gets the specified permission for the context
*
* @param Core_Model_Item_Abstract|string $resource The resource type or object that is being accessed
* @param Core_Model_Item_Abstract $role The item (user) performing the action
* @param string $action The name of the action being performed
* @return mixed 0/1 for allowed, or data for settings
*/
public function isAllowed($resource, $role, $action = 'view')

函数期望的 $resource 和 $role 对象是 Zend_Db_Table_Row 的实例,在 SocialEngine 中被称为模型,并且期望位于模块的模型目录中。当 isAllowed 函数被调用时,授权 api 将针对 engine4_authorization_allow、engine4_authorization_levels 和 engine4_authorization_permissions 表查询数据库。

  1. engine4_authorization_levels 表包含由 SocialEngine 开箱即用创建的成员级别,以及从管理面板中的“管理”>“成员级别”部分创建的自定义成员级别。
  2. engine4_authorization_permissions 表包含所有默认和管理员指定的权限处理,例如成员级别设置。
  3. engine4_authorization_allow 包含单个对象的权限数据。例如,关于谁能够查看相册的信息将被放置在那里。是否允许 engine4_authorization_allow.role_id(映射到模型的项目 ID)访问 engine4_authorization_allow.resource_id(映射到模型的项目 ID)由 engine4_authorization_allow.value 列确定,该列应包含数字 0-5。

应用程序/模块/授权/Api/Core.php

class Authorization_Api_Core extends Core_Api_Abstract
{
/**
* Constants
*/
const LEVEL_DISALLOW = 0;
const LEVEL_ALLOW = 1;
const LEVEL_MODERATE = 2;
const LEVEL_NONBOOLEAN = 3;
const LEVEL_IGNORE = 4;
const LEVEL_SERIALIZED = 5;

0) 不允许访问链接的资源。这与允许表中不存在的行相同

1) 也允许访问链接的资源

2) 允许访问和管理资源(即超级管理员、管理员和版主成员级别)

3-5) 被忽略为不允许。这些期望一些自定义逻辑以便适当地处理授权。

活动提要

发布到活动提要实际上非常简单。它或多或少是一个函数调用:

$api = Engine_Api::_()->getDbtable('actions', 'activity');
$api->addActivity($subject, $object, $action_type, $body, $params);

上面示例中的第一行使用 SocialEngines Engine_Api 类来加载 Activity_Model_DbTable_Actions 类(application/modules/Activity/Model/DbTable/Actions.php)。第二行是实际创建活动提要项的操作。

  1. $subject 和 $object 应该是 Core_Model_Item_Abstract(SocialEngine 模型)的实例。
  2. $action_type 是 engine4_activity_actiontypes 表中的一个动作
  3. $body 将存储在数据库中的 engine4_activity_actions.body 列。这是活动的实际消息。例如,当用户添加新的个人资料照片时,正文列将设置为:

    {item:$subject} added a new profile photo

    组装活动内容时,{item:$subject} 将替换为用户的显示名称

  4. $params 将被序列化并存储在 engine4_activity_actions.params 列中。组装活动描述时将传递params列中的数据:

    应用程序/模块/活动/模型/Action.php

    class Activity_Model_Action extends Core_Model_Item_Abstract
    {
    ...
    public function getContent()
    {
    $model = Engine_Api::_()->getApi('core', 'activity');
    $params = array_merge(
    $this->toArray(),
    (array) $this->params,
    array(
    'subject' => $this->getSubject(),
    'object' => $this->getObject()
    )
    );
    //$content = $model->assemble($this->body, $params);
    $content = $model->assemble($this->getTypeInfo()->body, $params);
    return $content;
    }
    
于 2012-09-07T17:56:43.503 回答
1

如果您可以从数据库访问,您可以尝试连接到该数据库并提取您的数据。但是,如果您通过 API 这样做可能是最好的

于 2012-05-23T10:46:46.087 回答
1

社交引擎中没有内置 REST API,因此您需要自己编写或向第三方社交引擎供应商索取 API。

于 2015-01-15T04:14:51.423 回答
0

这里有一个可用于 SocialEngine 4.x 的 HTTP/JSON API,它具有上述功能等等。 http://www.socialengine.com/customize/se4/mod-page?mod_id=1408 http://www.ipragmatech.com/socialapi-rest-socialengine.html

免责声明:我为本 API 的开发者 iPragmatech Solutions 工作。

于 2015-01-16T17:37:44.313 回答
0

在 socialengine 中,所有活动都有 engine4_activity_actions 表。我建议将此插件用于社交引擎的所有 REST API。该插件的文档是http://docs.socialengineapi.apiary.io/

并且该插件位于 socialengine https://www.socialengine.com/customize/se4/mod-page?mod_id=1408

于 2015-01-20T04:53:02.450 回答