manzadey / tilda

Tilde项目与其自建网站API集成

维护者

详细信息

github.com/Manzadey/tilda

源代码

问题

资助包维护!
Open Collective

v0.2 2021-10-30 16:49 UTC

This package is auto-updated.

Last update: 2024-09-29 05:57:02 UTC


README

该包旨在处理与Tilda API集成相关的Tilda

安装

composer require manzadey/tilda

如何使用

首先需要创建一个实例类,我们将进一步与之交互

use Manzadey\Tilda\Client;

$tilda = new Client('publicKey', 'secretKey');

本包实现了API集成提供的所有方法。

所有与API集成相关的函数都返回一个具有以下方法的类实例 Response

use Manzadey\Tilda\Client;

$tilda = new Client('publicKey', 'secretKey');

$projects = $tilda->getProjectsList();

$projects->getData(); // Возвращает полный ответ сервера в формате array
$projects->getResult(); // Возвращает информацию полученную от сервера в формате array, если ошибка вернёт null
$projects->getStatus(); // Возвращает булево значение результата ответа
$projects->getErrorMessage() // Возвращает сообщение об ошибке, если нет возвращает null

方法列表

项目列表

use Manzadey\Tilda\Client;

$tilda = new Client('publicKey', 'secretKey');

$tilda->getProjectsList();

响应

^ Manzadey\Tilda\Response {#27 ▼
  -data: array:2 [▼
    "status" => "FOUND"
    "result" => array:1 [▼
      0 => array:3 [▼
        "id" => "12345677"
        "title" => "title"
        "descr" => ""
      ]
    ]
  ]
}

项目信息

use Manzadey\Tilda\Client;

$tilda = new Client('publicKey', 'secretKey');

$tilda->getProjectInfo(123456);

响应

^ Manzadey\Tilda\Response {#21 ▼
  -data: array:2 [▼
    "status" => "FOUND"
    "result" => array:6 [▼
      "id" => "3739512"
      "title" => "ibin24"
      "descr" => ""
      "customdomain" => "ibin24.store"
      "css" => array:11 [▶]
      "js" => array:15 [▶]
    ]
  ]
}

项目导出信息

use Manzadey\Tilda\Client;

$tilda = new Client('publicKey', 'secretKey');

$tilda->getProjectExport(123456);

响应

^ Manzadey\Tilda\Response {#28 ▼
  -data: array:2 [▼
    "status" => "FOUND"
    "result" => array:14 [▼
      "id" => ""
      "title" => ""
      "descr" => ""
      "customdomain" => ""
      "export_csspath" => ""
      "export_jspath" => ""
      "export_imgpath" => ""
      "indexpageid" => ""
      "favicon" => ""
      "page404id" => "0"
      "images" => array:1 [▶]
      "htaccess" => ""
      "css" => array:11 [▶]
      "js" => array:15 [▶]
    ]
  ]
}

项目中的页面列表

use Manzadey\Tilda\Client;

$tilda = new Client('publicKey', 'secretKey');

$tilda->getPageList(123456);

响应

^ Manzadey\Tilda\Response {#19 ▼
  -data: array:2 [▼
    "status" => "FOUND"
    "result" => array:13 [▼
      0 => array:11 [▼
        "id" => ""
        "projectid" => ""
        "title" => ""
        "descr" => ""
        "img" => ""
        "featureimg" => ""
        "alias" => ""
        "date" => ""
        "sort" => ""
        "published" => ""
        "filename" => ""
      ]
      1 => array:11 [▶]
      2 => array:11 [▶]
      3 => array:11 [▶]
      4 => array:11 [▶]
      5 => array:11 [▶]
      6 => array:11 [▶]
      7 => array:11 [▶]
      8 => array:11 [▶]
      9 => array:11 [▶]
      10 => array:11 [▶]
      11 => array:11 [▶]
      12 => array:11 [▶]
    ]
  ]
}

页面信息 (+ body html-code)

use Manzadey\Tilda\Client;

$tilda = new Client('publicKey', 'secretKey');

$tilda->getPageInfo(789);

响应

^ Manzadey\Tilda\Response {#33 ▼
  -data: array:2 [▼
    "status" => "FOUND"
    "result" => array:12 [▼
      "id" => ""
      "projectid" => ""
      "title" => ""
      "descr" => ""
      "img" => ""
      "featureimg" => ""
      "alias" => ""
      "date" => ""
      "sort" => ""
      "published" => ""
      "filename" => ""
      "html" => ""
    ]
  ]
}

页面信息 (+ fullpage html-code)

use Manzadey\Tilda\Client;

$tilda = new Client('publicKey', 'secretKey');

$tilda->getPageFull(789);

响应

^ Manzadey\Tilda\Response {#34 ▼
  -data: array:2 [▼
    "status" => "FOUND"
    "result" => array:22 [▼
      "id" => ""
      "projectid" => ""
      "title" => ""
      "descr" => ""
      "img" => ""
      "featureimg" => ""
      "alias" => ""
      "date" => ""
      "sort" => ""
      "published" => ""
      "filename" => ""
      "export_jspath" => ""
      "export_csspath" => ""
      "export_imgpath" => ""
      "export_basepath" => ""
      "project_alias" => ""
      "page_alias" => ""
      "project_domain" => ""
      "html" => ""
      "images" => array:63 [▶]
      "js" => array:15 [▶]
      "css" => array:11 [▶]
    ]
  ]
}

页面导出信息 (+ body html-code)

use Manzadey\Tilda\Client;

$tilda = new Client('publicKey', 'secretKey');

$tilda->getPageExport(789);

响应

^ Manzadey\Tilda\Response {#18 ▼
  -data: array:2 [▼
    "status" => "FOUND"
    "result" => array:22 [▼
      "id" => ""
      "projectid" => ""
      "title" => ""
      "descr" => ""
      "img" => ""
      "featureimg" => ""
      "alias" => ""
      "date" => ""
      "sort" => ""
      "published" => ""
      "filename" => ""
      "export_jspath" => ""
      "export_csspath" => ""
      "export_imgpath" => ""
      "export_basepath" => ""
      "project_alias" => ""
      "page_alias" => ""
      "project_domain" => ""
      "html" => ""
      "images" => array:63 [▶]
      "js" => array:15 [▶]
      "css" => array:11 [▶]
    ]
  ]
}

页面导出信息 (+ fullpage html-code)

use Manzadey\Tilda\Client;

$tilda = new Client('publicKey', 'secretKey');

$tilda->getPageFullExport(789);

响应

^ Manzadey\Tilda\Response {#35 ▼
  -data: array:2 [▼
    "status" => "FOUND"
    "result" => array:22 [▼
      "id" => ""
      "projectid" => ""
      "title" => ""
      "descr" => ""
      "img" => ""
      "featureimg" => ""
      "alias" => ""
      "date" => ""
      "sort" => ""
      "published" => ""
      "filename" => ""
      "export_jspath" => ""
      "export_csspath" => ""
      "export_imgpath" => ""
      "export_basepath" => ""
      "project_alias" => ""
      "page_alias" => ""
      "project_domain" => ""
      "html" => ""
      "images" => array:63 [▶]
      "js" => array:15 [▶]
      "css" => array:11 [▶]
    ]
  ]
}

附加信息

有两个方法用于“项目”和“页面”实体

use Manzadey\Tilda\Client;

$tilda = new Client('publicKey', 'secretKey');

// Project Entity:
$tilda->getProject(123456)->info(); // $tilda->getProjectInfo(123456)
$tilda->getProject(123456)->export(); // $tilda->getProjectExport(123456)
$tilda->getProject(123456)->pages(); // $tilda->getPageList(123456)

// Page Entity:
$tilda->getPage(789)->info(); // $tilda->getPage(789)
$tilda->getPage(789)->fullInfo(); // $tilda->getPageFull(789)
$tilda->getPage(789)->export(); // $tilda->getPageExport(789)
$tilda->getPage(789)->fullExport(); // $tilda->getPageFullExport(789)