Having problems with Mailchimp API Editing Member of a list - php

Its not working for some odd reason.
http://apidocs.mailchimp.com/api/2.0/lists/update-member.php
I want to update the Notes section on a member.
Its acting like it posts fine.
returning a valid response no error code.
but its not adding a new note to the member.
$results = $MailChimp->call("lists/update-member",
array(
"id"=> "xxxxxxx",
"email" => array(
"email" => "someemail#gmail.com",
"euid" => "xxxxxxx"
),
"merge_vars" => array(
"mc_notes" => array(
"note" => "THIS IS MY NEW NOTE"
)
),
"update_existing"=> true,
));
var_dump($results);

Related

Facebook Marketing API get campaign info

I'm using the code autogenerated by facebook to try and connect to the marketing API to get campaign stats. In doing so, I'm getting:
Uncaught FacebookAds\Http\Exception\AuthorizationException: (#100) results, actions:like, video_play_actions:video_view, video_avg_time_watched_actions:video_view, unique_actions:link_click are not valid for fields param.
$fields = array(
'results',
'reach',
'actions:like',
'video_play_actions:video_view',
'video_avg_time_watched_actions:video_view',
'unique_actions:link_click',
);
var_dump($fields);
$params = array(
'level' => 'campaign',
'filtering' => array(array('field' => 'campaign.delivery_info','operator' => 'IN','value' => array('active'))),
'breakdowns' => array(),
'time_range' => array('since' => '2017-05-19','until' => '2019-05-19'),
);
echo json_encode((new AdAccount($ad_account_id))->getInsights(
$fields,
$params
)->getResponse()->getContent(), JSON_PRETTY_PRINT);
Above I used campaign.delivery_info per this answer. I've also tried (per the auto-generated code):
'filtering' => array(array('field' => 'delivery_info','operator' => 'IN','value' => array('active')))
Seems you are asking for old values field, try this:
$fields = array(
'reach',
'actions',
'video_play_actions',
'video_avg_time_watched_actions',
'outbound_clicks',
);
Hope this help
NB: results field is not available

Add Organisation & Contact to Insightly and automatically link them

I am using a PHP library (https://github.com/Insightly/insightly-php) with great success for the Insightly API. More information on the Insightly API can be found here: https://api.insight.ly/v2.2/Help
My goal is to have an organisation and a contact added to Insightly on a form submission and to then link the two together. I can add the organisation and the contact without any issues but I am having troubles linking the two afterwards. When I add in the code to link the two it is only adding the organisation and not the contact.
Please view my code below:
$organization = $i->addOrganization($newOrganization);
$getOrganizationID = $i->getOrganization($company);
$id = json_decode($getOrganizationID, true);
$newContact = (object)array(
"FIRST_NAME" => $first_name,
"LAST_NAME" => $last_name,
"CONTACTINFOS" => array(
(object)array(
"TYPE" => "EMAIL",
"LABEL" => "WORK",
"DETAIL" => $email,
),
(object)array(
"TYPE" => "PHONE",
"LABEL" => "WORK",
"DETAIL" => $phone,
)
),
"LINKS" => array(
(object)array(
"ORGANISATION_ID" => $id[0]['ORGANISATION_ID'],
)
),
);
$contact = $i->addContact($newContact);
I had a faulty link in the getOrganization() function and have since fixed it.

DocuSign REST API (PHP) - pre-fill custom tags

I am working on project in which I need to use DocuSign API (PHP). This is my first experience with DocuSign and I successfully made template in DocuSign Console with roleName = signer. There I also made Custom Text Tags: address, city, state and phone and drag them to the desired location in my template. I want there to put my customer (signer) information from project database.
From my project I successfully made connection with DocuSign via PHP API and receive Embedded Singing View URL which opens my template where the user can sign document without problem.
But... all my custom text tags are empty and signer can type into them. I need to pre-fill them with signer personal data which is coming from database. I triple check custom tag label spelling, upper/lower case in my DocuSign Console and in my code as well as roleName->tagLabel relation. My PHP code is below.
Can someone, please, tell me what I am doing wrong?
I lost two days on it.
$data = array(
"accountId" => $accountId,
"emailSubject" => $this->_emailSubject,
"templateId" => $templateId,
"templateRoles" => array(
array(
"email" => $email,
"name" => $recipientName,
"clientUserId" => $clientUserId,
"roleName" => "signer",
"customFields" => array(
"textCustomFields" => array (
array (
"name" => "address",
"value" => "Address from DB",
"show" => "true",
),
array (
"name" => "city",
"value" => "City from DB",
"show" => "true",
),
array (
"name" => "state",
"value" => "State from DB",
"show" => "true",
),
array (
"name" => "phone",
"value" => "Phone from DB",
"show" => "true",
),
),
),
),
),
"status" => "sent"
);
You need to use the textTabs type in your JSON, not customFields which is used for something else. For instance, if you drag a Data Field from the UI onto the document and give it name address, to pre-fill that field you would need to reference it's tabLabel and value fields like this:
"roleName" => "signer",
"tabs" => array(
"textTabs" => array(
array(
"tabLabel"=> "address",
"value" => "123 Main St."
)
)
)

Prepopulating Docusign Template Fields

So I'm trying to prepopulate some fields in our DocuSign Templates when submitting them from our custom interface but the request doesn't seem to be able to find them in the templates. We're using REST, cURL and Codeigniter. My data array is as follows:
$data = array("accountId" => $accountId,
"emailSubject" => "Hello World!",
"emailBlurb" => "This comes from PHP",
"templateId" => "********-****-****-****-************",
"templateRoles" => array(
array(
"email" => "****#******.com",
"name" => "**** *****",
"roleName" => "LC3"
),
array(
"email" => $this->input->post("applicant_email"),
"name" => $this->input->post("applicant_name"),
"roleName" => "Applicant",
"tabStatuses" => array(
"textTabs" => array (
array (
"tabLabel" => "lic_num",
"tabValue" => $this->input->post("license_number")
),
array (
"tabLabel" => "ubi_num",
"tabValue" => $this->input->post("ubi_number")
),
array (
"tabLabel" => "tra_nam",
"tabValue" => $this->input->post("trade_name")
)
)
)
)
),
"status" => "sent");
I tried tabs instead of tabStatuses, but that didn't work either and our XML responses have TabStatuses instead of Tabs. Has something changed since the API Walkthroughs were put up?
EDIT: So after much trial and error with Chrome's Postman extension, this is the JSON request that I got to actually not error out:
{
"accountId":"c771ba8c-2947-4bec-acab-15b1b48a11b6",
"emailSubject":"Hello World!",
"emailBlurb":"This comes from PHP",
"templateId":"B96D0480-8792-43E8-AE11-E2AEAC74E601",
"templateRoles":[
{
"email":"mike#cloudpwr.com",
"name":"Mike Longmire",
"roleName":"LC3",
"tabStatuses":[
{
"tabStatus":[
{
"tabLabel":"lic_num",
"tabValue":"1111"
},
{
"tabLabel":"ubi_num",
"tabValue":"2222"
},
{
"tabLabel":"tra_nam",
"tabValue":"Flakey"
}
]
}
],
"email":"duckie715#gmail.com",
"name":"Mike Longmire",
"roleName":"Applicant"
}
],
"status":"sent"
}
I get back my same response:
{
"envelopeId": "0063d398-36b7-4e2f-8515-6ed9ab62aaeb",
"uri": "/envelopes/0063d398-36b7-4e2f-8515-6ed9ab62aaeb",
"statusDateTime": "2013-10-08T18:05:54.9926661Z",
"status": "sent"
}
Any ideas?
This is most likely caused by the values being returned from your function calls inside the JSON not being wrapped by quotation (") marks. To test that theory I would first just hardcode some values wherever you have a function call in your JSON (such as "email" => $this->input->post("applicant_email")) and replace with actual emails, etc and run.
If you still get the 400 error then something else is wrong with your request. If you don't, then you just need to prepend and append quotes around the values that are passed back by those function calls.
For instance, you can assign to variables, such as
$applicantEmail_1 = $this->input->post("applicant_email")
then setup your JSON like:
"templateRoles" => array(
array(
"email" => "****#******.com",
"name" => "**** *****",
"roleName" => "LC3"
),
array(
"email" => "$applicantEmail_1",
"name" => $this->input->post("applicant_name"),
"roleName" => "Applicant",
...
The nice thing about PHP is that even though that variable is in double quotes the value of the variable will still be inserted inside the quotes.

How to log dimension like AWS CloudWatch bundled metric

Can anyone explain how to use the AWS PHP SDK to log the metric in the style like the above screen.
I use the following PHP code but the select menu is showing "ELB: AvaliabiltyZone", how to make it show "Aggregated by AvaliabiltyZone"? What is the logic used here?
$response = $cw->put_metric_data("ELB", array(
array(
"MetricName" => "Latency",
"Dimensions" => array(
array("Name" => "AvaliabiltyZone" , "Value" => "us-east-1c")
),
"Timestamp" => "now",
"Value" => 1,
"Unit" => "None"
),
));
AvaliabiltyZone
You misspelled "AvailabilityZone"
This maybe won't answer the question, but it might fix some things...
$cw = new AmazonCloudWatch();
$cw->set_region('monitoring.'.$region.'amazonaws.com');
$res1 = $CW->put_metric_data('Sys/RDS' ,
array(array('MetricName' => 'Uptime' ,
'Dimensions' => array(array('Name' => 'AvaliabiltyZone',
'Value' => 'us-east-1c')),
'Value' => $Uptime,
'Unit' => 'Seconds')));
Click Here

Categories