activecampaign / activecampaign-api-php Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
It would be helpful if the response object implemented an iterator interface when the data includes an array so that something like this would work as expected:
$lists = api("list/list", array("ids" => "all");
if ($lists->success) {
foreach($lists as $list) {
echo $list->id;
}
}
Intuitively that would just iterate through the lists, but currently it includes all visible properties of the object so you can't really use it like that. I realize that iterating over $lists->{0}
will work instead, but just thought I would suggest this improvement. Thanks!
-Garrett
Hello. I found that $sdk->api('list/field_view', ['ids' => 'all']);
not works.
But native request to API with list_field_view
endpoint returns fields list
Hi,
the response of list/view
contains the array "fields". This array contains Infos about the custom fields of that list. But only if the "list" options of these fields (inside active campaign) are set specifically. If I choose the "all" option, then the "fields" array of the list/view
response doesn't contains Infos about that field.
Example:
I got list foo
and list bar
.
I got the fields baz
and qux
.
In the options of baz
I set the lists specifically to foo
and bar
.
In the options of qux
I set the lists to "all".
Now the list/view
responses of foo
and bar
only contains infos about baz
. The Infos about qux
are missing.
Greetings
Christian
The version in the ActiveCampaign.class.php file is 1.
I tried to use the API call $AC->api("contact/tag/add", $aPostData);
But it gave me an error: An unexpected problem occurred with the API request. Some causes include: invalid JSON or XML returned. Here is the actual response from the server: ----
To fix it, I changed a line in the Contact.class.php file.
Line number: 88
Old code: $response = $this->curl($request_url, $post_data);
New code: $response = $this->curl($request_url, $post_data, 'POST');
And now it works, so I think you need to add this too.
i need to get all the lists using API key so that i can add leads to particular list.
Hi
am using active campaign api
$activeCampaign->version(2);
$contacts_view = $activeCampaign->api("contact/list"); its working but when am applying filer its not working
example:
$contacts_view = $activeCampaign->api("contact/list?email=[email protected]");
$contacts_view = $activeCampaign->api("contact/list?datetime=2015-03-10");
also i want to know a way how i can get the today added contact list.
Please mention any api call or way so i can know how many new contact add today?
I have also used version one by get the error
Result: FAILED
Message: Failed: Nothing is returned
The entire result printed out:
Array
(
[result_code] => 0
[result_message] => Failed: Nothing is returned
[result_output] => serialize
)
Raw response printed out:
a:3:{s:11:"result_code";i:0;s:14:"result_message";s:27:"Failed: Nothing is returned";s:13:"result_output";s:9:"serialize";}
Please inform me if you need my api key and url
attempting to show autologin screen... i am consistently getting this error: Unknown command: singlesignon
I know that by getting to this step, I have all folder and classes included correctly, but I am very unsure on why this would be calling this error.
assuming this function is NOT being called correctly: https://github.com/ActiveCampaign/activecampaign-api-php/blob/master/includes/Auth.class.php#L17
from this step: https://github.com/ActiveCampaign/example-reseller_account_manage/blob/master/index.php#L204
any guidance would be appreciated...
Sorry if this is a dumb question but I can not find anywhere in the onsite edition information how to generate an API KEY for use with the API. It is in settings in the online version but I can't find the onsite. A hint would be much appreciated.
This is more an issue with cURL, but use of this settings in the Connector class spits a warning and disables following of the Location
header (and that I assume can have consequences). I do not care about possible compatibility with safe_mode
, as it is removed as of 5.4.0, but open_basedir
is a good security add-on that I do not want to get rid of.
Did you consider changing handling of Location
- from the cURL CURLOPT_FOLLOWLOCATION
to manual mode? (there are snippets available)
An unexpected problem occurred with the API request. Some causes include: invalid JSON or XML returned. Here is the actual response from the server: ----
Hi, contact view by id or email is not working at all..the API was updated but the code not..for instance if I use contact/view and provide a param email ..it should resolve to contact_view_email but it resolves to contact_view and does not return any results if I want to view a contact by it's id I must use a trick to do it like contact/view?id= because if I use id in params it does not return anything
I am able to get the sample code to work from https://www.activecampaign.com/api/example.php?call=campaign_list to return all campaigns with a filter applied for sending date. However I can not get it to work with this library package.
I have the following
$params = [
'filters[sdate_since_datetime]' => '2017-10-30 05:00:00'
];
$campaigns = $ac->api( "campaign/list?ids=all", $params);
$results = [];
foreach($campaigns as $campaign){
$results[] = [
'id' => $campaign->id,
'sdate' => $campaign->sdate,
'name' => $campaign->name
];
}
echo "<pre>";
print_r( $results );
echo "</pre>";
The first issue is that you can't have 'ids' => 'all
in the $params
array. If you do that it will return no results. The second issue is that it doesn't matter what I pass in the $params array, it never actually gets passed.
What am I doing wrong here?
details can be found at #55
the example.php script doesn't work ATM: it echoes, which produces warnings when the Connector class calls the header function, and the api calls are outright wrong. I've cloned this repo and put together a little patch:
From b410cff219bc9d1dc5749651d34acb44e64476b4 Mon Sep 17 00:00:00 2001
From: EVODelavega <[email protected]>
Date: Fri, 21 Mar 2014 14:12:34 +0100
Subject: [PATCH] Fixed (some) of the examples.php calls: add output buffering
to avoid warning when calling header, ensure the correct call URI is used
(account/view-> user/view?id=X, contact/sync should be subscriber/sync and
the like)
---
examples.php | 15 +++++++++++----
1 file changed, 11 insertions(+), 4 deletions(-)
diff --git a/examples.php b/examples.php
index 94ebcf7..2025c54 100644
--- a/examples.php
+++ b/examples.php
@@ -2,6 +2,8 @@
require_once("includes/ActiveCampaign.class.php");
+ ob_start();
+
$ac = new ActiveCampaign(ACTIVECAMPAIGN_URL, ACTIVECAMPAIGN_API_KEY);
/*
@@ -15,12 +17,14 @@
else {
echo "<p>Credentials valid! Proceeding...</p>";
}
-
/*
* VIEW ACCOUNT DETAILS.
*/
- $account = $ac->api("account/view");
+ //$account = $ac->api("account/view");
+ //should be user/view, and requires id param to work
+ //change id to whatever id works, 2, 3... play around
+ $account = $ac->api('user/view?id=1');
echo "<pre>";
print_r($account);
@@ -64,7 +68,9 @@
"status[{$list_id}]" => 1, // "Active" status
);
- $contact_sync = $ac->api("contact/sync", $contact);
+ //$contact_sync = $ac->api("contact/sync", $contact);
+ //object is called contact, but URI should be subscriber, subscriber class basically extends contact anyway
+ $contact_sync = $ac->api('subscriber/sync', $contact);
if ((int)$contact_sync->success) {
// successful request
@@ -143,7 +149,8 @@
echo "<pre>";
print_r($campaign_report_totals);
echo "</pre>";
+ ob_end_flush();
?>
-<a href="http://www.activecampaign/api">View more API examples!</a>
\ No newline at end of file
+<a href="http://www.activecampaign/api">View more API examples!</a>
--
1.8.3.2
Hi. I have a server with PHP 5.6 and the library works, but i move the code to another server with PHP 5.2, and the library doesn't work.
What is the minimun requirements for this library ? i need add other functions to the other PHP server for use this library ?
I'm currently using composer to manage dependancies in my project, but would rather specify a specific version of activecampaign-api-php than use 'dev-master'.
Using 'dev-master' means that every time I run 'composer update', composer will bring in any changes to activecampaign-api-php since I last ran the command. This could lead to bugs or api changes in the library breaking my code.
It is summed up nicely in this stack overflow thread: http://stackoverflow.com/questions/14243190/dev-master-in-composer-json-is-this-madness
Thanks :)
Trying to sync a field using a personalisation tag has no effect on the field (I think I am using the correct syntax as specified in api docs:
<?php
$ac = new ActiveCampaign('xxx', 'xxx');
$array = [
'email' => '[email protected]',
'field[%care_type%,0]' => 'Value'
];
$ac->api("contact/sync", $array);
I can make it work correctly by specifying the id instead:
<?php
$ac = new ActiveCampaign('xxx', 'xxx');
$array = [
'email' => '[email protected]',
'field[3,0]' => 'Value'
];
$ac->api("contact/sync", $array);
I could just be missing something obvious, but as far as I can tell from the docs, the first example should work.
Thanks
Hi, after launching my script to add contacts to Active Campaign through contact_sync this error occurres.
Fatal error: Uncaught RequestException: An unexpected problem occurred with the API request. Some causes include: invalid JSON or XML returned. Here is the actual response from the server: ---- in C:\Users\uzivatel\Desktop\folder\name\includes\Connector.class.php:209 Stack trace: #0 C:\Users\uzivatel\Desktop\folder\name\includes\Contact.class.php(87): AC_Connector->curl('https://directa...', Array) #1 C:\Users\uzivatel\Desktop\folder\name\includes\ActiveCampaign.class.php(109): AC_Contact->sync('', Array) #2 C:\Users\uzivatel\Desktop\folder\name\functions.php(82): ActiveCampaign->api('contact/sync', Array) #3 C:\Users\uzivatel\Desktop\folder\name\AC-DB-NEW.php(10): contacts(Object(mysqli_result), Object(ActiveCampaign)) #4 {main} thrown in C:\Users\uzivatel\Desktop\folder\name\includes\Connector.class.php on line 209
Any idea on how to fix that?
I've tried a few different paths and I'm fairly sure this is a bug.
$contact = $ac->api('contact/view/email', array(
'email'=>'[email protected]'
));
To fix I'm adding the following method to class AC_Contact
function view_email($params, $post_data) {
$request_url = "{$this->url}&api_action=contact_view_email&api_output={$this->output}&{$params}";
$response = $this->curl($request_url, $post_data);
return $response;
}
Currently having an issue where there is a connection made to the API, but the API is very slow (Been loading for a few minutes). This in turn block the whole website.
I suggest adding the following to the curl function
curl_setopt($ch, CURLOPT_CONNECTTIMEOUT ,0);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
So that if after 10 second in total CURL will stop. 10 seconds should be long enough for this API.
I am trying to add custom fields to the contact like in described in the api:
http://www.activecampaign.com/api/example.php?call=contact_add
// ...
'field[345,0]' => 'field value',
the response error is the following:
There was an error processing custom field 345. Try encoding each 'field[]' parameter
A lot has changed since the 1.0.0 release over a year ago, could you create another?
This is important for those of us using composer as part of deployment, as it means we can be sure our dependencies are the same in all instances of our codebase.
I tried to access the contact_automation_list endpoint from the AC API (http://www.activecampaign.com/api/example.php?call=contact_automation_list) but couldn't find the corresponding function here, so it throws an error. Could this be added?
Hello, I was unable to install the library using composer because of the:
"require": {
"lib-curl": "*"
}
That package does not seem to exist on composer, did you mean lib/curl?
It is possible to get (list) the lists and add a list but everything else ends up in a "You are not authorized to access this file" - Response.
I executed the examples.php and got following output:
"Credentials valid! Proceeding...
stdClass Object
(
[result_code] => 0
[result_message] => You are not authorized to access this file
[result_output] => json
[http_code] => 200
[success] => 0
[error] => You are not authorized to access this file
)
List added successfully (ID 7)!
Syncing contact failed. Error returned: You are not authorized to access this file"
I executed this script locally from my computer within a virtual host and the active campaign installation runs remotely accessible.
the script require autoload script which is missing...
require 'vendor/autoload.php'
anybody can help ?
Please consider adding PHPDoc with proper annotations for type hinting. Thanks!
In the following lines you simply return what the error is. It's better to throw an exception. Explicit is better than implicit.
I found an issue where the list_field_view ('list/field_view') command didn't return any data, and originally thinking it was an API bug, it's actually bug with this wrapper. The issue is purely that parameters are not being passed on to the API due to a small error in the code.
More details here:
https://community.activecampaign.com/t/looks-like-a-bug-with-list-field-view-api-call/3243
In List.class.php, here's where $post_data is missing:
function field_view($params) { $request_url = "{$this->url}&api_action=list_field_view&api_output={$this->output}&{$params}"; $response = $this->curl($request_url); return $response; }
And now added, where it works perfectly:
function field_view($params, $post_data) { $request_url = "{$this->url}&api_action=list_field_view&api_output={$this->output}&{$params}"; $response = $this->curl($request_url, $post_data); return $response; }
Sharing in the hope that this fix will get added to the wrapper :)
Thanks
Dan
Why this doesn't works? (the event not showing in user activity)
$activeCampaign->track_actid = $this->trackId;
$activeCampaign->track_key = $this->trackKey;;
if ($email) {
$activeCampaign->track_email = $email;
}
$request = [
'event' => 'login',
'visit' => [
"url" => 'http://www.example.com'
]
];
$response = $activeCampaign->api("tracking/log", $request);
if (!$response->success) {
// it's true
}
but this does works? (the event shows up in user activity)
$curl = curl_init();
curl_setopt($curl, CURLOPT_URL, "https://trackcmp.net/event");
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, array(
"actid" => $this->trackId,
"key" => $this->trackKey,
"event" => "login",
"visit" => json_encode([
"email" => $email,
],
))
);
So, composer is made to handle PSR0 autoloading. There shouldn't be a need for require_once include calls. Your documentation has instructions for installing composer too, and that the lib will be available after installing composer.
Let's assume people know how to install composer and if not, a link should suffice, that whole section is confusing and if you're having a composer section, it should be the composer install for the lib itself only. Include the json config or command line details for composer install and let the autoload.php handle autoloading, without the confusion of require_once.
Include another section for people that are using php libs the older way.
Overall the docs are confusing and could use a little more standardization. You might have a look at some other common php libs for example docs. Thanks!
Hi there,
I am signing up to an upgrade in AC soon and I am starting to prepare my custom WordPress plugin to move from my old emailing system to AC.
I can see that the v2 is in the pipeline but could you let me know when is the v2 planned to be released for?
Thanks!
The example I found in the documentation uses raw curl
to add new contacts. I did some reading on the classes and I believe there's a way to add contacts using this wrapper, but I couldn't find any example. The code I have is like this:
require_once 'includes/ActiveCampaign.class.php';
$API_URL = "myurl";
$API_KEY = "myapikey";
$ac = new ActiveCampaign($API_URL, $API_KEY);
$mycontactEmail = "[email protected]";
$mycontactName = "Name Example";
Since I have the object, could some help me telling how it would be to add a new contact?
I will keep reading the code, but an example will make my job faster. ๐
#72
Hi All
I know about campaign_send you mentioned API.
But for that i need campaign id first. And when i create campaign it need list ld so i want to send campaign without list id only contact.
In Issue #1 mthommes commented on Dec 21, 2012
Just an update for anyone else following this thread - campaign_send will only work if the campaign has sent already (completely finished and sent). If you are trying to use campaign_send prior to sending the actual campaign, it will return "Message not sent."
So my need is to create campaign and send or schedule email campaign at the same time when i select contact without lists.
Hope you understand all.
I want to Send email to particular subscriber(contact).
not the Lists (not selecting Lists ) only selected subscriber(contact) of a Lists.
How to send Campaign email using API.
Is there any API for Send Campaign email to particular contact only.
This is request code:
$activecampaignObj->api('tags/list');
Response i got is :
An unexpected problem occurred with the API request. Some causes include: invalid JSON or XML returned. Here is the actual response from the server: ---- [{"id":1,"name":"Tag 1","count":0},{"id":2,"name":"Tag 2","count":0}]
Example.php has a sample for contact/sync. Is there a sample of the use for contact/list? Not clear on the parameters passed there. Looking to find a contact by something other than email address.
Send email to particular subscriber(contact).
Hi Peter Evans
I know about campaign_send you mentioned API.
But for that i need campaign id first. And when i create campaign it need list ld so i want to send campaign without list id only contact.
In Issue #1 mthommes commented on Dec 21, 2012
Just an update for anyone else following this thread - campaign_send will only work if the campaign has sent already (completely finished and sent). If you are trying to use campaign_send prior to sending the actual campaign, it will return "Message not sent."
So my need is to create campaign and send or schedule email campaign at the same time when i select contact without lists.
Hope you understand Now.
I was trying this $fields = $ac->api("list/field/view", array("ids" => "all");
and it gave me no result at all. Then 40 minutes later in a moment of inspiration I tried this $fields = $ac->api("list/field/view?ids=all");
which worked. Please document the behaviour!
And I would much prefer the first way of doing things because it feels a lot more natural.
(ping @ac-pevans)
Hey guys, and thanks in advance.
I did the composer install.. No issue there.. But Laravel only allows classes to run in a provider/facade method, in their own namespace.
Do you have any laravel instructions?
Hello
this is the delete request:
https://xxx.api-us1.com/admin/api.php?api_key=XXX&api_action=contact_delete&api_output=json&
Note that the "id" field is missing (http://www.activecampaign.com/api/example.php?call=contact_delete)
The delete method in AC_Contact class could accept the contact id to be deleted:
function delete($params, $id) { $request_url = "{$this->url}&api_action=contact_delete&api_output={$this->output}id={$id}"; ... }
and the call could be:
$response = $ac->api('contact/delete', $contactId);
Is there a way to query for all tags that have been set up in ActiveCampaign?
Please add interfaces. The value of this should go without further elaboration. Thanks!
I have a system set up for people to send a preview email of a scheduled campaign from the api
the following is always returning an error:
$response = $ac->api("campaign/send?email=$email_test&campaignid=$cid&messageid=0&type=mime&action=send");
where $email_test is an email address and $cid is the campaign id of a scheduled campaign.
It is worth noting that I had a similar issue in september.
Hi,
We are using your activecampaign library and we want to print details about the result from API calls.
And as the library uses HTTP POST headers to make calls, we get notice error :
Warning Error: Cannot modify header information - headers already sent
How can we resolve this issue?
Thanks
Hi there,
I've got an issue - any help would be appreciate - thanx in advance if you can help me
$ac = new ActiveCampaign(ACTIVECAMPAIGN_URL, ACTIVECAMPAIGN_API_KEY);
var_dump($ac->api("account/view")); // works fine
var_dump($ac->api("list/list",array( "ids"=>"all"))); // works fine
// Failed: Nothing is returned but i do have campaigns returned by the API explorer
var_dump($ac->api("campaign/list",array( "ids"=>"all")));
// Failed: Nothing is returned but i do have campaigns returned by the API explorer
var_dump($ac->api("user/list",array( "ids"=>2684))); // also tried with array("2684") as ids
// ERROR
var_dump($ac->api("user/view",array( "id"=>2684)));
// ERROR (email exists in our base)
var_dump($ac->api("user/view",array( "email"=>"[email protected]")));
The message returned by the user/view function is
An unexpected problem occurred with the API request. Some causes include: invalid JSON or XML returned. Here is the actual response from the server: ----
1You are not authorized to access this file
Hi there
I tried to view the subscriber with their email via activecampaign-api-php, but it is showing "
You are not authorized to access this file" error, it is working fine, if I login our active campaign backend and generate code via system (http://newsletters.mymagazines.com.au/newsletter/screenshot.png). Would you please help me that? Check the error link here http://newsletters.mymagazines.com.au/newsletter/test.php, thanks a lot.
Regards
Robin
Will this repo be made composer-aware, and/or registered with packagist? I'm currently working on a symfony2 project, and it sure would make things easier. I've forked this repo and begun refactoring the code (adding namespaces, and removing bulk)
Rather than going into a re-write frenzy, I was wondering if playing the waiting game wasn't an option, too
I want to get all the deals so i can count the total number of them from the API.
There is a limit of 20 records per page. I want to bypass it and get all the deals so i can count it.
I'm using this: https://appterra.api-us1.com/admin/api.php?api_action=deal_list&api_key={this is a secret}&full=1
Please help me. I've been browsing these for 2 days...
Any examples/tutorials for using webhooks?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.