Kevin.a
Kevin.a

Reputation: 4286

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/

Upvotes: 2

Views: 113

Answers (1)

Kevin.a
Kevin.a

Reputation: 4286

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

Upvotes: 2

Related Questions