How to add a contact to a list in ActiveCampaign API v3 - activecampaign

According to v3 docs I should be able to add a contact to a list using the Contact API but I am at a loss on how to do so as I see nothing list related under Contacts.
How do I add a contact to a list (not through automations) using version 3 of the API? Or are the docs in error?

The v3 docs have been updated (Lists documentation) and they no longer read that you can add a contact to a list through the API. ActiveCampaign Lists documentation screenshot
EDIT: you can add a contact to a list using the v1 contact_sync (contact_sync documentation)
SECOND EDIT: you can now add a contact to a list and/or change their subscription status to a given list through the v3 API!
(update list status for a contact documentation)

The above is no longer true. You can add a contact using the Create Contact endpoint.
It's basically a POST request that uses the following parameters:
E-Mail (Required)
First Name (Optional)
Last Name (Optional)
Phone (Optional)
The API v3 changed a lot though and now after you create a contact to do the following this you have to consult other endpoints. For example:
To add a contact to a list you need a POST request to the Contact Lists endpoint where you need to provide three parameters (listid, contactid, status).
If you need to assign a tag to a contact, in order to be able to create the relationship you first need to create the tag using the Create a new tag endpoint. And the use the resulting tag id with the Create Contact Tag endpoint where you combine said tag id with the contact id.
Now in order to remove that same tag the guys from Active Campaign made us work more and in order to remove a tag from a contact you don't use the contact's id and the tag's id, but rather you have to use the contact's id and the relationship id between the tag and the specific contact, that's quite a lot of steps, but I guess they wanted to make it very robuts in terms of structure.
There are many new endpoints which were actually available from around the date when you asked your question. You should check out the new API reference. It has some flaws and is not 100% complete yet, but it would be useful.

Hope this helps since it gave me some head heck... Using activecampaign php sdk when adding a contact with the sync command you can also add it to a list:
$list_id = 'thelistid';
$contact = array(
"email" => 'contactemail#doamin.com',
"p[{$list_id}]" => $list_id,
"status[{$list_id}]" => 1, // "Active" status
);
$contact_sync = $ac->api("contact/sync", $contact);
They wrote it also as examples on the repository but for some reason I didn't catch it.

Related

Basecamp 3 API : How to get comments created by the authorized user?

I am in the process of integrating my webapp with Basecamp 2 (solved, see edit) and 3, and I want to get all of the comments for a todo item for the authorized user.
First I make a call to https://launchpad.37signals.com/authorization.json which returns json that includes the user's identity, something like {"identity":{"id":99999999, ..... }}.
Then I make a call to the URL to get the comments for the item in question and go through them one by one matching the identity.id from above (99999999) with the creator.id for the comment.
The problem is, they don't match! I am working with one Basecamp2 project and one Basecamp3 project. When testing, using comments I wrote, Basecamp2 and Basecamp3 each have different values for creator.id (even though I wrote both comments!), and neither of them match the identity.id from authorization.json.
How do I link them to find which comments were made by the authorized user
Thanks
EDIT: I figured it out for Basecamp2 - I need to get /people.json which has a mapping from the identity_id of each user to the id for that user in that project. Still not sure how to do it for Basecamp3, which does not include identity_id in people.json!
The correct way to do this for Basecamp2 is to get:
https://basecamp.com/{project_id}/api/v1/people/me.json - the id node contains the id of the authorized user for project {project_id}.
for Basecamp3:
https://3.basecampapi.com/{project_id}/my/profile.json - the id node contains the id of the authorized user for project {project_id}.

Neto API Limitations

I'm currently attempting to integrate with the Neto Ecommerce API. I've hit all sorts of limitations that I never see on other platforms and the latest is to do with custom fields.
The API Im using is the GetOrders API, and Im following the requirements to fetch transaction information, however custom fields appear to be missing. Hoping someone out there has made use of this API to extract custom fields and can advise on how to go about getting custom field information.
Any tips appreciated
var netoString = '{"Filter":{"OrderID":[""],"OutputSelector":["ID","ShippingOption","DeliveryInstruction","RelatedOrderID","cust1"]};
Is there an undocumented naming convention used to fetch custom fields or other pattern I can try to see if I can fetch the data?
I am not certain this will be the same for the API, but when using exports the correct format to access Custom Sales Order Fields is "customer_ref1".
To get a Custom Customer Fields is "usercustom1"
Note: For the Custom Customer Fields, the numbers do not match up correctly (I.E. usercustom1 doesn't match misc1 in the cpanel). The correct matches are:
misc1=usercustom1
misc2=usercustom4
misc3=usercustom5
misc4=usercustom6
misc5=usercustom7
misc6=usercustom11
misc7=usercustom12
misc8=usercustom13
misc9=usercustom14
misc10=usercustom15
misc11=usercustom16
misc12=usercustom17
misc13=usercustom18
misc14=usercustom19
misc15=usercustom20
misc16=usercustom21
misc17=usercustom22
misc18=usercustom23
misc19=usercustom24
misc20=usercustom25
misc21=usercustom10
misc22=usercustom26
misc23=usercustom27
misc24=usercustom28
misc25=usercustom29
misc26=usercustom30
misc27=usercustom31
misc28=usercustom32
misc29=usercustom33
misc30=usercustom34
misc31=usercustom35
misc32=usercustom36
misc33=usercustom37
misc34=usercustom38
misc35=usercustom39
misc36=usercustom40

Get BlogPost based on Taxonomy

I'm trying to create a custom Blog post rotator for a homepage. It shows the 5 newest posts (Title, summary, date, and link) this works with the following code
var posts = App.WorkWith().BlogPosts().Publihed().Get().OrderByDescending(p => p.PublicationDate).Take(5)ToList();
But I only want to get posts with specific Tags. I'm able to get the Guid associated with a specific tag
TaxonomyManager taxmanager = TaxonomyManager.GetManager();
var taxonGuidId = taxmanager.GetTaxa<FlatTaxon>().Where(t => t.Name == "SpecificTag").Single().Id;
I can foreach through every post and see lots of information but cannot figure out how to determine if the specific Guid is attached to that post. Or take the post and get a list of Taxon; something like
var postTaxon = GetTaxon(BlogPost)
Is there a reason you need to use a custom widget? I would recommend using the standard list widget for blogs select the tag you want to show and then limit it to 5. Once you do that you can then us your JavaScript to create the rotator from the default classes or modify the template to have custom classes.

Create direct url to LinkedIn company update

I'm implementing a Compony newsfeed on a website and ran into the following problem. The LinkedIn API doesn't provide a direct URL to a company update. Looking at the LinkedIn site there are direct URL's and they're like this for example:
https://www.linkedin.com/company/1441/comments?topic=5849556347070205952&type=U&scope=1441&stype=C&a=5uHW&goback=%2Ebzo_*1_*1_*1_*1_*1_*1_*1_1441
Trying stuff out it seems that the parameters topic, type, scope, stype and a are mandatory for the URL to work.. (goback is the only one that isn't).
Using the LinkedIn API with the Company updates call I'm able to buid the direct url, except for the a parameter. The value is always 4 (for me unexplainable) characters long.
Has anyone ever successfully build a direct URL to a company update or can someone maybe explain the a parameter or how to generate its value?
Updated to new format
You can link directly to any update (company or user) using the following url:
https://www.linkedin.com/feed/update/urn:li:activity:[topic_id]
You can get [topic_id] by getting the last bit of the updateKey in the api response from Linkedin. When updateKey = UPDATE-c7352-6410848097894756353, your topic_id = 6410848097894756353.
In your example that would become https://www.linkedin.com/feed/update/urn:li:activity:5849556347070205952 which links directly to the specific update. The post is too old to work with the new link format
The url used to be
https://www.linkedin.com/nhome/updates/?topic=[topic_id]
Updated thanks to the comment from #sethpollack
For anyone trying to get the topic id from the API response object (as already commented on the OP question), the topic id is the value after the last hyphen of the updateKey property, which can be used with #Daan answer:
"updateKey": "UPDATE-cXXXX-YYYYYYYYYYYYYYYYYY"
Direct URL:
https://www.linkedin.com/nhome/updates?topic=[YYYYYYYYYYYYYYYYYY]
Using the URL format above, get the topic_id by opening the update in its own window/tab, look at the page source code in your browser and search for the string :activity: the long number after the string is the infamous topic_id

REST API: How to search for other attribute

I use node.js as REST API.
There are following actions available:
/contacts, GET, finds all contacts
/contacts, POST, creats new contact
/contacts/:id, GET, shows or gets specifiy contact by it's id
/contacts/:id, PUT, updates a specific contact
/contacts/:id, DELETE, removes a specific contact
What would now be a logic Route for searching, quering after a user?
Should I put this to the 3. route or should I create an extra route?
I'm sure you will get a lot of different opinions on this question. Personally I would see "searching" as filtering on "all contacts" giving:
GET /contacts?filter=your_filter_statement
You probably already have filtering-parameters on GET /contacts to allow pagination that works well with the filter-statement.
EDIT:
Use this for parsing your querystring:
var url = require('url');
and in your handler ('request' being your nodejs http-request object):
var parsedUrl = url.parse(request.url, true);
var filterStatement = parsedUrl.query.filter;
Interesting question. This is a discussion that I have had several times.
I don't think there is a clear answer, or maybe there is and I just don't know it or don't agree with it. I would say that you should add a new route: /contacts/_search performing an action on the contacts list, in this case a search. Clear and defined what you do then.
GET /contacts finds all contacts. You want a subset of all contacts. What delimiter in a URI represents subsets? It's not "?"; that's non-hierarchical. The "/" character is used to delimit hierarchical path segments. So for a subset of contacts, try a URI like /contacts/like/dave/ or /contacts/by_name/susan/.
This concept of subsetting data by path segments is for more than collections--it applies more broadly. Your whole site is a set, and each top-level path segment defines a subset of it: http://yoursite.example/contacts is a subset of http://yoursite.example/. It also applies more narrowly: /contacts/:id is a subset of /contacts, and /contacts/:id/firstname is a subset of /contacts/:id.