skyfrog/activecampaign-api-php
Composer 安装命令:
composer require skyfrog/activecampaign-api-php
包简介
An alternative, more PSR-compliant AC API wrapper
关键字:
README 文档
README
This is a fork of the official PHP wrapper for the ActiveCampaign API. It differs from the original in the sense that this fork is composer aware, uses namespaces and makes it easy to use the API wrapper in projects created with MVC frameworks like Zend2 or Symfony2.
Installation
As stated, this fork is composer-aware, though not actually registered with packagist (it's on my TODO list ;-P).
For now, adding the the following to your composer.json file will (have to) do:
"repositories": [ { "type": "vcs", "url": "https://github.com/EVODelavega/activecampaign-api-php.git" } ], "require": { "EVODelavega/activecampaign-api-php": "dev-master" }
If you so desire, there is a postUpdate/postInstall script available that allows you to re-write the config.php file in this repo, to define the ACTIVECAMPAIGN_URL and ACTIVECAMPAIGN_API_KEY constants.
Though, as shown in the Symfony2 example below, this is optional. This fork does not use these constants anywhere.
If you wish to use this script, though, edit your composer file like so:
"scripts": { "post-install-cmd": [ "AC\Connector::postUpdate" ], "post-update-cmd": [ "AC\Connector::postUpdate" ] }
Either one of these two is fine, though probably post-update-cmd is to be preferred.
By default, the config falls back to the "hosted" mode (behaviour similar to the "master" branch of the original repo). Instead of creating a separate oonsite branch, the AC\Arguments\Config object can be set to "onsite" mode, using the class constants and/or constructor arguments.
The mode can, of course, be set on the fly, too.
Example (Symfony2)
To use the Acme bunle like the official Symfony2 cookbook, here's an example of how to use this repo:
- In you bundle dir (src/AcmeBunle), create/edit the services.yml file (AcmeBundle/Resources/config/services.yml):
parameters: ac: url: http://your.activecampaign.url apiKey: yourACkeyHash apiUser: userName apiPass: OptionalPass(hash) output: json (default output, can be changed on the fly) mode: onsite (or hosted, can be changed on-the-fly, too)
- Then set up the service that will be accessing the api in such a way that it will be passed these params:
services: your_api_service: class: "%theClass%" calls: - [setActiveCampaignConfig, [%ac%]]
- When that's done, add the corresponding properties and methods to the service class in question
<?php namespace AcmeBundle\Service; use AC\Arguments\Config, AC\ActiveCampaign; /** * Your service class doc-block */ class YourService { /** * @var \AC\ActiveCampaign */ protected $api = null; /** * @var \AC\Arguments\Config */ protected $config = null; /** * Is called by service locator * @param array $config * @return \AcmeBundle\Service\YourService */ public function setActiveCampaignConfig(array $config) { $this->config = new Config($config); return $this; } public function getActiveCampaignConfig() { return $this->config; } /** * Lazy-load the api interface * @return \AC\ActiveCampaign */ public function getActiveCampaignAPI() { if ($this->api === null) { $this->api = new ActiveCampaign( $this->getActiveCampaignConfig() ); } return $this->api; } }
- After this, you're all set to use the api in much the same way the examples.php file uses it:
/** * Example method, perhaps to add to the ficticious class listed above * @param array $contact * @return \stdClass **/ public function syncContact(array $contact) { //returns existing ActiveCampaign instance, or creates one if required $api = $this->getActiveCampaignApi(); return $api->api('contact/sync', $contact); }
Of course, you're free to expand on this by, for example, creating a Contact class, and distil from that a correctly formatted array that the API can work with.
Either way, this is why this fork was created, and this is how it was originally used.
Background
This API fork is far from finished. I had to use the API wrapper in a project, but as it was not composer-aware, and the original repo made composer-autoloading a cough challange cough, I used my PyPHPScanner to quickly refactor it a bit, added the composer.json file, and implemented some ghastly magic-methods.
These magic-methods will be made obsolete in the near future, the ActiveCampaign::api method's ability to cache API calls will be expanded on, and after that, I'll see what else I can do. For now, though, feel free to use this fork, and don't hesitate to fork yourself!
Of course, share and share alike: pull-requests are greatly appreciated.
ORIGINAL README:
This is the official PHP wrapper for the ActiveCampaign API. The purpose of these files is to provide a simple interface to the ActiveCampaign API. You are not required to use these files (in order to use the ActiveCampaign API), but it's recommended for a few reasons:
- It's a lot easier to get set up and use (as opposed to coding everything from scratch on your own).
- It's fully supported by ActiveCampaign, meaning we fix any issues immediately, as well as continually improve the wrapper as the software changes and evolves.
- It's often the standard approach for demonstrating API requests when using ActiveCampaign support.
Both customers of our hosted platform and On-Site edition can use these files. On-Site customers should clone the source and switch to the "onsite" branch, as that is geared towards the On-Site edition. Many features of the hosted platform are not available in the On-Site edition.
Installation
You can install activecampaign-api-php by downloading or cloning the source.
Click here to download the source (.zip) which includes all dependencies.
require_once("includes/ActiveCampaign.class.php");
Fill in your URL and API Key in the includes/config.php file, and you are good to go!
Example Usage
includes/config.php
define("ACTIVECAMPAIGN_URL", "https://ACCOUNT.api-us1.com");
define("ACTIVECAMPAIGN_API_KEY", "njasdf89hy...23ad7");
examples.php
require_once("includes/ActiveCampaign.class.php");
$ac = new ActiveCampaign(ACTIVECAMPAIGN_URL, ACTIVECAMPAIGN_API_KEY);
$account = $ac->api("account/view");
Or just include everything in the same PHP file:
define("ACTIVECAMPAIGN_URL", "https://ACCOUNT.api-us1.com");
define("ACTIVECAMPAIGN_API_KEY", "njasdf89hy...23ad7");
require_once("includes/ActiveCampaign.class.php");
$ac = new ActiveCampaign(ACTIVECAMPAIGN_URL, ACTIVECAMPAIGN_API_KEY);
$account = $ac->api("account/view");
See our examples file for more in-depth samples.
Full Documentation
Click here to view our full API documentation.
Reporting Issues
We'd love to help if you have questions or problems. Report issues using the Github Issue Tracker or email help@activecampaign.com.
skyfrog/activecampaign-api-php 适用场景与选型建议
skyfrog/activecampaign-api-php 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 133 次下载、GitHub Stars 达 0, 最近一次更新时间为 2022 年 12 月 05 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「newsletter」 「Forms」 「automation」 「subscribe」 「emails」 「activecampaign」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 skyfrog/activecampaign-api-php 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 skyfrog/activecampaign-api-php 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 skyfrog/activecampaign-api-php 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
ConfirmationField is a form field for Atk14 applications. It's like the BooleanField (checkbox) but the ConfirmationField must be ticked.
Field for number with restricted count of digits and decimal places
Command-line utility for Vtiger CRM.
Historical accounting for contacts
Manage newsletters in Laravel
HTML and form generation
统计信息
- 总下载量: 133
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2022-12-05