I have integrated infusionsoft PHP API with my website. As Iam currently pass only name and email address of the subscriber. Now I would like pass all available field values to API.
Just Click on Add contact in Infusionsoft you would see form with all avaliable fields. Just inspect and you will get to know the name attribute value for each field. Just Contact0 in the name field use only postfix value. for ex, contact0First_name is name attribute value of firstname., In which we should use only First_name just ignore "contact0"
Here I provide code...
$contact = array(
'Email' => $user_details['email'],
'FirstName' => $user_details['name'],
'StreetAddress1' => $user_details['address'],
'State' => $user_details['state'],
'City' => $user_details['city'],
'PostalCode' => $user_details['zip'],
'Country' => $user_details['country'],
'Company' => $user_details['company'],
'JobTitle' => $user_details['jobtitle'],
'Phone1' => $user_details['phone'],
'Fax1' => $user_details['fax'],
'Website' => $user_details['website'],
'Contact0TwitterSocialAccountName' => $user_details['twitter']
);
Related
Here is a screenshot from an app that I have in podio. I am trying to set the address field via a php script. The following is how I set my fields.
$field->values = array(
'value' => $latLong['address'],
'lat' => $latLong['latitude'],
'lng' => $latLong['longitude']
);
From the item activity feed is shows that the address was updated. But when you look at the actual item, the address location is blank, but it has the right map location. Any ideas on what is causing this issue?
Try setting value a bit differently :)
addr_full = { 'street_address' => 'some street address here',
'postal_code' => 'some zip code, eg: 90210',
'city' => 'Beverly Hills',
'state' => 'CA',
'country' => 'United States' }
Sorry, code is from Ruby but it shouldn't be hard to convert it to php syntax.
I'm working with an API.
With an array I collect data like this:
$org_payload = array(
'name' => $_POST['billing_company'],
'phone' => $_POST['billing_phone'],
'email' => $_POST['billing_email'],
'note' => $_POST['order_comments'],
'relation_type' => array(
'id'=>'relationtype:c1ec3ae77036842d' //provide the relationtypeid, f.e. relationtype:796ce0d318a2f5db515efc18bba82b90
),
'visiting_address' => array(
'country_code' => 'NL',
'line_1' => $_POST['billing_address_1'],
'postal_code' => $_POST['billing_postcode'],
'locality' => $_POST['billing_city'],
'country' => $_POST['billing_country']
), // can be extented with other address data
'postal_address' => array(
'country_code' => 'NL'
) // can be extented with other address data
);
At one point i send this data to the program i'm working with. I achieve this with this code:
$organization = $SimplicateApi->makeApiCall('POST','/crm/organization',json_encode($org_payload));
I gather this data from a form on my website. This data gets posted in the program.
I am trying to achieve that when data gathered from my form matches existing data in the program then don't add it. I would like a hint in the right direction for this, been looking on the internet without any luck.
What I would suggest is to have one extra call to the API.
Like you said in the comments - the company name and the phone number is unique.
If there is some call to get a user by those values and check what you got from the form, would be enough.
If they are unique - send them,
if not - show to the user or whatever you want to do here.
No need to keep one more database on your system as well.
I use Laravel 5 to develop an app and I use Mailchimp for adding subscription. I use Mailchimp v.3 . I can make a list using this code:
$mailchimp = new Mailchimp(xxxxxxxxxxxx-xx);
$contact = [
'company' => $request['campaign'],
'address1' => $request['address'],
'city' => $request['city'],
'state' => $candidate->userCandidate->state,
'zip' => $request['zip'],
'country' => $request['country'],
'phone' => $request['phone'],
];
$campaign_details = [
'from_name' => $request['from_name'],
'from_email' => $request['from_email'],
'subject' => $request['remind_text'],
'language' => 'English'
];
$data = [
'name' => Auth::user()->name . ' Campaign',
'contact' => $contact,
'permission_reminder' => $request['remind_text'],
'campaign_defaults' => $campaign_details,
'notify_on_subscribe' => $request['from_email'],
'notify_on_unsubscribe' => $request['from_email'],
'email_type_option' => false,
'visibility' => $request['visibility'],
];
$list = $mailchimp->post('lists', $data);
I use this library drewm/mailchimp. My code on subscribing is this:
$mailchimp = new Mailchimp($api_key);
$subscriber = [
'email_type' => 'html',
'email_address' => $email,
'language' => 'English',
'status' => 'subscribed',
'merge_fields' => ['zip' => $zip]
];
$result = $mailchimp->post('lists/' . $list_id . '/members', $subscriber);
And I can successfully subscribe it. This is my question how to verify an email first before will be recorded on mailchimp list to avoid spammer. I read on mailchimp that they have DOUBLE OPT-IN method but it is only available if you use their form.
My solution is to email first on subscriber and create a link for verifying and this solution can take time. Is there another solution on this? Does Mailchimp have method to acquire this?
I don't have any idea on Mailchimp API. However, you just have to set up an email validation flow first. In this way, all emails will not be considered as "spam" in your records. Then you're free to do any email tasks without worrying if it is valid or not.
The quick answer to your question is to set the status to "pending" instead of "subscribed", but you should check out MailChimp's docs on managing subscribers with API v3 for more details.
MailboxValidator does have an easy import feature to grab your list from MailChimp for email validation purposes. Then it automatically updates your MailChimp list once the validation process is done.
https://www.mailboxvalidator.com/resources/articles/how-to-import-email-list-from-mailchimp/
Situation: Checkout as guest (no customer billing address in database).
Problem: How to fill out the billing address form automatically using variables from url or session?
Perfect solution for me would to be:
change as less as possible e.g. in this file
app/design/frontend/default/my_theme_name/template/persistent/checkout/onepage/billing.phtml
and access variables this way
$this->getAddress()->getName();
My temporary solution:
/* array comes from url or session */
$myAddress = array (
'firstname' => 'John',
'lastname' => 'Smith',
'street' => array (
'0' => '1st Street',
'1' => '2056',
),
'city' => 'Maspeth',
'region_id' => '',
'region' => '',
'postcode' => 'NY11378',
'country_id' => 'US',
'telephone' => '0017183209872'
);
$customAddress = Mage::getModel('customer/address');
$customAddress->setData($myAddress);
/* $this = Mage_Checkout_Block_Onepage_Billing */
$this
->setBillingAddress(Mage::getSingleton('sales/quote_address')
->importCustomerAddress($customAddress));
/* insert value into input field */
echo $this->getBillingAddress()->getName();
$this
->setBillingAddress(Mage::getSingleton('sales/quote_address')
->importCustomerAddress($customAddress));
Do no use "$this" here it have to be a Quote object (Mage_Sales_Model_Quote) and not a Billing Block (Mage_Checkout_Block_Onepage_Billing). Use $this->getQuote().
I have built an API that I want to test. By that reason I'm building a simple client to try out the different features (CRUD). Below is the function for updating a producer, which works fine. However, I also want to be able to update parts of a producer, e.g. address (/producers/8?method=put&address=milkyway).
The array producer always contains the same elements (name, address, zipcode etc) but I only want to update the producer with the elements in the array which contains of anything. What I mean with that is that if for example the name element in the array is empty then name shouldn't be included in *http_build_query*. If only the name element contains of anything then only name should be updated.
So, let's say that the array (except for id that of course is mandatory) contains of address. How can I dynamically add only that to *http_build_query* ?
Thanks in advance!
public function UpdateProducer($producer) {
$url = 'http://localhost/webbteknik2/Labb2/api/v1/producers/ . $producer['id'] . '?method=put';
$data = http_build_query(array(
'name' => $producer['name'],
'address' => $producer['address'],
'zipcode' => $producer['zipcode'],
'town' => $producer['town'],
'url' => $producer['url'],
'imgurl' => $producer['imgurl'],
'latitude' => $producer['latitude'],
'longitude' => $producer['longitude'],
));
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
...
the rest of the curl code
}
Note: I know this is bad coding in many ways, but as I said I only, asap want to be able to test the CRUD functionality through the client.
use array_filter to remove the empty elements....
$params = array(
'name' => $producer['name'],
'address' => $producer['address'],
'zipcode' => $producer['zipcode'],
'town' => $producer['town'],
'url' => $producer['url'],
'imgurl' => $producer['imgurl'],
'latitude' => $producer['latitude'],
'longitude' => $producer['longitude'],
);
$data = http_build_query(array_filter($params, 'is_null'));