[wordpress插件] Active Collab 5 SDKActive Collab 5 SDK

wordpress 插件 文章 2020-01-28 06:40 598 0 全屏看文

AI助手支持GPT4.0

评分

100

100

描述

Connecting to Active Collab Cloud Accounts

连接到Active Collab云帐户

`php

 `php

<?php

require_once ‘/path/to/vendor/autoload.php’;

require_once‘/path/to/vendor/autoload.php’;

// Provide name of your company, name of the app that you are developing, your email address and password.

//提供您的公司名称,正在开发的应用程序的名称,您的电子邮件地址和密码。

$authenticator = new \ActiveCollab\SDK\Authenticator\Cloud(‘ACME Inc’, ‘My Awesome Application’, ‘you@acmeinc.com’, ‘hard to guess, easy to remember’);

$ authenticator = new \ ActiveCollab \ SDK \ Authenticator \ Cloud(“ ACME Inc”,“ My Awesome Application”,“ you@acmeinc.com”,“难以猜测,易于记忆”);

// Show all Active Collab 5 and up account that this user has access to.

//显示该用户有权访问的所有Active Collab 5及更高版本的帐户。

print_r($authenticator->getAccounts());

print_r($ authenticator-> getAccounts());

// Show user details (first name, last name and avatar URL).

//显示用户详细信息(名字,姓氏和头像URL)。

print_r($authenticator->getUser());

print_r($ authenticator-> getUser());

// Issue a token for account #123456789.

//为帐户#123456789发行令牌。

$token = $authenticator->issueToken(123456789);

$ token = $ authenticator-> issueToken(123456789);

// Did we get it?

//我们明白了吗?

if ($token instanceof \ActiveCollab\SDK\TokenInterface) {
    

if($ token instanceof \ ActiveCollab \ SDK \ TokenInterface){
    

print $token->getUrl() .

打印$ token-> getUrl()。

“\n”;
    

“ \ n”;
    

print $token->getToken() .

打印$ token-> getToken()。

“\n”;

“ \ n”;

} else {
    

} else {
    

print “Invalid response\n”;
    

打印“无效的响应\ n”;
    

die();

die();

}
    

}
    

Connecting to Self-Hosted Active Collab Accounts

php

连接到自托管的Active Collab帐户 php

require_once ‘/path/to/vendor/autoload.php’;

require_once‘/path/to/vendor/autoload.php’;

// Provide name of your company, name of the app that you are developing, your email address and password.

//提供您的公司名称,正在开发的应用程序的名称,您的电子邮件地址和密码。

Last parameter is URL where your Active Collab is installed.

最后一个参数是安装Active Collab的URL。

$authenticator = new \ActiveCollab\SDK\Authenticator\SelfHosted('ACME Inc', 'My Awesome Application', 'you@acmeinc.com', 'hard to guess, easy to remember', 'https://my.company

$ authenticator = new \ ActiveCollab \ SDK \ Authenticator \ SelfHosted('ACME Inc','My Awesome Application','you@acmeinc.com','难以猜测,易于记忆','https://my.company

.com/projects');

.com / projects');

// Issue a token.

//发行令牌。

$token = $authenticator->issueToken();

$ token = $ authenticator-> issueToken();

// Did we get what we asked for?

//我们得到了我们想要的东西吗?

if ($token instanceof \ActiveCollab\SDK\TokenInterface) {
    

if($ token instanceof \ ActiveCollab \ SDK \ TokenInterface){
    

print $token->getUrl() .

打印$ token-> getUrl()。

“\n”;
    

“ \ n”;
    

print $token->getToken() .

打印$ token-> getToken()。

“\n”;

“ \ n”;

} else {
    

} else {
    

print “Invalid response\n”;
    

打印“无效的响应\ n”;
    

die();

die();

}
    

}
    

`

`

SSL problems?

SSL问题?

If curl complains that SSL peer verification has failed, you can turn it off like this:

如果curl抱怨SSL对等验证失败,则可以这样关闭它:

`php

 `php

// Cloud

//云

$authenticator = new \ActiveCollab\SDK\Authenticator\Cloud(‘ACME Inc’, ‘My Awesome Application’, ‘you@acmeinc.com’, ‘hard to guess, easy to remember’, false);

$ authenticator = new \ ActiveCollab \ SDK \ Authenticator \ Cloud(“ ACME Inc”,“ My Awesome Application”,“ you@acmeinc.com”,“难以猜测,易于记忆”,错误);

$authenticator->setSslVerifyPeer(false);

$ authenticator-> setSslVerifyPeer(false);

// Self-hosted

//自托管

$authenticator = new \ActiveCollab\SDK\Authenticator\SelfHosted('ACME Inc', 'My Awesome Application', 'you@acmeinc.com', 'hard to guess, easy to remember', 'https://my.company

$ authenticator = new \ ActiveCollab \ SDK \ Authenticator \ SelfHosted('ACME Inc','My Awesome Application','you@acmeinc.com','难以猜测,易于记忆','https://my.company

.com/projects', false);

.com / projects',false);

$authenticator->setSslVerifyPeer(false);

$ authenticator-> setSslVerifyPeer(false);

// Client

//客户端

$client = new \ActiveCollab\SDK\Client($token);

$ client = new \ ActiveCollab \ SDK \ Client($ token);

$client->setSslVerifyPeer(false);
    

$ client-> setSslVerifyPeer(false);
    

`

`

Note: Option to turn off SSL peer verification has been added in Active Collab SDK 3.1.

注意:已在Active Collab SDK 3.1中添加了用于关闭SSL对等验证的选项。

Constructing a client instance

构建客户端实例

Once we have our token, we can construct a client and make API calls:

有了令牌后,我们就可以构建一个客户端并进行API调用:

`php

 `php

$client = new \ActiveCollab\SDK\Client($token);
    

$ client = new \ ActiveCollab \ SDK \ Client($ token);
    

`

`

Listing all tasks in project #65 is easy.

列出项目65中的所有任务很容易。

Just call:

只需致电:

`php

 `php

$client->get(‘projects/65/tasks’);
    

$ client-> get(‘projects / 65 / tasks’);
    

`

`

To create a task, simply send a POST request:

要创建任务,只需发送一个POST请求:

`php

 `php

try {
    

尝试{
    

$client->post(‘projects/65/tasks’, [
      

$ client-> post(“ projects / 65 / tasks”,[
      

‘name’ => ‘This is a task name’,
      

‘name’=>‘这是一个任务名称’,
      

‘assignee_id’ => 48
    

‘assignee_id’=> 48
    

]);

]);

} catch(AppException $e) {
    

} catch(AppException $ e){
    

print $e->getMessage() .

打印$ e-> getMessage()。

‘;
    

’;
    

// var_dump($e->getServerResponse());

// var_dump($ e-> getServerResponse());

(need more info?)

(需要更多信息吗?)

}
    

}
    

`

`

To update a task, PUT request will be needed:

要更新任务,需要PUT请求:

`php

 `php

try {
    

尝试{
    

$client->put(‘projects/65/tasks/123’, [
        

$ client-> put('projects / 65 / tasks / 123',[
        

‘name’ => ‘Updated named’
    

‘name’=>‘Updated named’
    

]);

]);

} catch(AppException $e) {
    

} catch(AppException $ e){
    

print $e->getMessage() .

打印$ e-> getMessage()。

‘;
    

’;
    

// var_dump($e->getServerResponse());

// var_dump($ e-> getServerResponse());

(need more info?)

(需要更多信息吗?)

}
    

}
    

`

`

post()`` and ``put()`` methods can take two arguments:

  post()``和``put()``方法可以使用两个参数:

    1. command (required) – API command,
    2. 命令(必填)– API命令,

    3. variables – array of request variables (payload)
    4. 变量 –请求变量(有效载荷)数组

    To remove a task, call:

    要删除任务,请致电:

    `php

     `php

    try {
        

    尝试{
        

    $client->delete(‘projects/65/tasks/123’);

    $ client-> delete(‘projects / 65 / tasks / 123’);

    } catch(AppException $e) {
        

    } catch(AppException $ e){
        

    print $e->getMessage() .

    打印$ e-> getMessage()。

    ‘;
        

    ’;
        

    // var_dump($e->getServerResponse());

    // var_dump($ e-> getServerResponse());

    (need more info?)

    (需要更多信息吗?)

    }
        

    }
        

    `

    `

    delete()`` method only requires ``command`` argument to be provided.

      delete()``方法仅需要提供“ command”参数。

    For full list of available API command, please check Active Collab API documentation.

    有关可用API命令的完整列表,请查看 Active Collab API文档

    p>

    >

安装步骤

If you choose to install this application with Composer instead of pulling down the git repository you will need to add a composer.json file to the location you would like to pull the repository down to featuring:

如果您选择通过Composer安装此应用程序,而不是下拉git存储库,则需要将composer.json文件添加到您要将该存储库下拉为具有以下功能的位置:

`json

 `json

{
    

{
    

“require”: {
        

“要求”:{
        

“activecollab/activecollab-feather-sdk”: “^3.0”
    

“ activecollab / activecollab-feather-sdk”:“ ^ 3.0”
    

}

}

}
    

}
    

`

`

Run a composer update to install the package.

运行 composer更新以安装软件包。

Note: If you used an older version of Active Collab API wrapper and loaded it using dev-master, lock it to version 2.0 by setting require statement to

注意:如果您使用的是旧版本的Active Collab API包装器,并使用 dev-master 加载了它,则可以通过将require语句设置为

>^2.0 and calling composer update.

> ^ 2.0 并调用 composer update

下载地址

https://downloads.wordpress.org/plugin/active-collab-api.zip

https://downloads.wordpress.org/plugin/active-collab-api.zip

-EOF-

AI助手支持GPT4.0