Closed JoabMendes closed 8 years ago
Hi, thanks for reaching out. We have an examples script that shows how to add contacts, along with other common requests (using this wrapper). Let us know of any questions! :+1:
Hi @mthommes,
Now I am trying to get the ids of all my lists with this code:
//I am including the ActiveCampaign.class
//Also I defined the following constants in the config.php file
$ac = new ActiveCampaign(ACTIVECAMPAIGN_URL, ACTIVECAMPAIGN_API_KEY);
if (!(int)$ac->credentials_test()) {
echo "<p>Access denied: Invalid credentials (URL and/or API key).</p>";
exit();
}
//The test works already
$post_data = array(
'api_action' => 'list_list',
'api_key' => ACTIVECAMPAIGN_API_KEY,
'api_output' => 'json',
'ids' => 'all',
);
var_dump($ac->api("list/list_", $post_data));
But I'm always get the error: Trying to get property of non-object#0
Do you have any ideia of what I might be doing wrong?
Hi, your $post_data
doesn't need to be included at all. In fact list_list
is a GET
method and doesn't require post data. Second, maybe try doing just this: "list/list"
(instead of "list/list_"
- remove the underscore).
Let us know if that doesn't work still! :smiley:
Sadly, I still the the same error doing var_dump( $ac->api("list/list") );
When I run this code to test the $ac object
$ac = new ActiveCampaign(ACTIVECAMPAIGN_URL, ACTIVECAMPAIGN_API_KEY);
if (!(int)$ac->credentials_test()) {
echo "<p>Access denied: Invalid credentials (URL and/or API key).</p>";
exit();
}
var_dump(get_class_methods($ac)); //output here
I get its methods
array(6) { [0]=> string(11) "__construct" [1]=> string(7) "version" [2]=> string(3) "api" [3]=> string(16) "credentials_test" [4]=> string(3) "dbg" [5]=> string(4) "curl" }
So I have no idea of what's happening since the including and the calls seem to be right.
Try this:
$ac->api("list/list?ids=all");
Also set this (above the previous line):
$ac->debug = true;
It works when I specified the parameter in $ac->api("list/list?ids=all");
. I am getting all the lists.
Also, the first error wasn't coming from the wrapper. The problem was from the definition of my framework that was wrong, sorry.
Thanks for your amazing support.
Glad we could help! :+1:
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: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. :smiley: