Podio Address bug? - php

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.

Related

Getting JSON data

Im working with an api which stores data into a JSON file. This data is gathered from a form that the users fill in my website. The way its inserted goes as follow:
$pers_payload = array(
'gender' => 'Unknown', //or Male / Female
'first_name' => $_POST['billing_first_name'],
'family_name' => $_POST ['billing_last_name'],
'email' => $_POST['billing_email'],
'linked_as_contact_to_organization' => array(
array(
'organization_id' => $organization_id, // add the person as a contact to the newly created organization
'work_email' => $_POST['billing_email'],
'work_phone' => $_POST['billing_phone']
)
),
'visiting_address' => array(
'country_code' => 'NL'
), // can be extented with other address data
'postal_address' => array(
'country_code' => $_POST['billing_country']
) // can be extented with other address data
);
And then:
$person = $SimplicateApi->makeApiCall('POST','/crm/person',json_encode($pers_payload));
Now instead of post i want to get the data. I tried getting data like this:
$SimplicateApi->makeApiCall('GET','/crm/organization?q[name]=*my name*');
I dont know if this is the right way, well it didn't work so obviously its not.
Anyways what im trying to achieve is with PHP i want to gather the name value of an existing person. this data is stored in /api/v2/crm/person.json
Api documentation (which i read but didn't understand to well) http://api.simplicate.nl/
It's been a while but i'm trying to answer all my open questions without an answer which i ended up solving on my own.
So for this.
You have to create a variable which makes the get request like this:
$test = $SimplicateApi->makeApiCall('GET','/crm/organization?q[name]=My name');
Now you can for example do a var_dump($test);
And as output you will get all the data inside
/crm/organization?q[name]=My name

Check if data exists

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.

Fedex how to set preferred currency in PHP

Fedex seems to have very intuitive documentation and no code samples (besides the downloaded modules). I want to change the currency for the rates from fedex. In documentation/XML file I have found something like preferredCurrency. Similar to other attributes I'm trying to set it like this:
if($var == 'preferredcurrency') Return 'HUF';
but this is totally ignored (I tried also PreferredCurrency) and the returned rate is always $USD. Anyone is familiar with FEDEX API and can help?
UPDATE:
It's basically about requesting and receiving response. I have some function where I set parameters like:
function getProperty($var){
if($var == 'shipper') Return array(
'Contact' => array(
'PersonName' => 'Sender Name',
'CompanyName' => 'Sender Company Name',
'PhoneNumber' => '1234567890'
),
'Address' => array(
'StreetLines' => array('Address Line 1'),
'City' => 'SomeCity',
'StateOrProvinceCode' => 'SomeState',
'PostalCode' => '3434343',
'CountryCode' => 'US',
'Residential' => 1
)
);
}
and then in another file a request to fedex is made, like :
$request['RequestedShipment']['Shipper'] = array(
'Address'=>getProperty('address1')
);
All of this values are defined in an XML file, I'm trying to get rate including CurrencyExchangeRate like this:
$request['CurrencyExchangeRate'] = array(
'FromCurrency' => array('USD'),
'IntoCurrency' => array('HUF'),
'Rate' => array(1.0)
);
But this request is ignored and I don't know why.
Maybe you just have a misssing Element. The Docs are here: Shipment Docs.
$request['RequestedShipment']['PreferredCurrency'] = 'HUF' and
$request['RequestedShipment']['RateRequestTypes'] = 'PREFERRED'

How to pass all available parameters to infusionsoft API?

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']
);

Dynamically add fields to http_build_query

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'));

Categories