LEADS

Client level API for accessing a client's leads and lead information.

endpoint: https://api.idxbroker.com/leads/[...]

This is a simple, access anywhere, method for getting a list of all API components available.

  • GET

    • primary request ID: none
    • secondary request ID: none
    • additional input: none
    • output: all available APIs/Components
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/listcomponents';
    $method = 'GET';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$components = json_decode($response,true);
    else
    	$error = $code;
    											
  • POST None

  • PUT None

  • DELETE None

A simple method for listing all available methods in the current API component. This method will also list which request methods (GET, PUT, POST, or DELETE) are supported by each method.

  • GET

    • primary request ID: none
    • secondary request ID: none
    • additional input: none
    • output: basic information about all available methods in this API. Data includes:
      • Method Name
      • The list of actions (GET, POST, etc) and a boolean denoting whether or not the action is available in the method.
      • The method's status.
        • indev: This method is in development. Input or output may change without notice.
        • active: This method is operating normally.
        • deprecated: The functionality of this method is being superceeded by another as described in the method description.
        • sunset: This method is no longer available.
      • A one to two sentance description of the method.
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/listmethods';
    $method = 'GET';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$response = json_decode($response,true);
    else
    	$error = $code;
    											
  • POST None

  • PUT None

  • DELETE None

Get information for one or multiple leads. Also ability to add or modify single leads.

  • GET

    Get lead information for one or more leads.
    • primary request ID: leadID optional The ID of a lead.
    • secondary request ID: none
    • additional input: none
    • output: If a lead ID is provided detailed information about that lead is returned. Otherwise simple information about all leads is returned
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/lead';
    $method = 'GET';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$response = json_decode($response,true);
    else
    	$error = $code;
    											
  • POST

    Update the information for one lead specified by the primary request ID.
    • primary request ID: leadID required The ID of a lead.
    • secondary request ID: none
    • additional input: optional update fields in a URL encoded, ampersand delineated, query string format
    • output: If no POST data is supplied then a list of updatable fields with format information is returned
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/lead/1';
    $data = array(
    	'firstName'=>'Aaron',
    	'lastName'=>'Aaronson',
    	'email'=>'aaaaaaaaaronson@fake-email.com'
    );
    $data = http_build_query($data); // encode and & delineate
    $method = 'POST';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    // send the data
    curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$response = json_decode($response,true);
    else
    	$error = $code;
    											
  • PUT

    Create a new lead.
    • primary request ID: none
    • secondary request ID: none
    • additional input: optional update fields in a URL encoded, ampersand delineated, query string format
    • output: If a lead is successfully created the new lead's ID will be returned.
      If no PUT data is supplied then a list of updatable fields with format information is returned.
      Special note: Currently the API cannot differentiate between a lead rejected due to server error or one rejected due to bad email address. The lead system requires email addresses that are correctly formatted to cut down on garbage accounts, and they need to have a valid MX record. Most 500 error from this method are a result of bad email addresses. In future versions we will differentiate the error and make the MX record requirement optional.
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/lead';
    $data = array(
    	'firstName'=>'Aaron',
    	'lastName'=>'Aaronson',
    	'email'=>'aaaaaaaaaronson@fake-email.com'
    );
    $data = http_build_query($data); // encode and & delineate
    $method = 'PUT';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    // send the data
    curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$response = json_decode($response,true);
    else
    	$error = $code;
    											
  • DELETE None

  • GET None

  • POST None

  • PUT

    • primary request ID: none
    • secondary request ID: none
    • additional input: optional update fields in a URL encoded, ampersand delineated, query string format. Each lead field should be passed as an indexed array starting at and going to, at most, 100. There must not be any gaps.
    • output: If a lead is successfully created the new lead IDs will be returned. If no PUT data is supplied then a list of updatable fields with format information is returned.
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/bulklead';
    $data = array(
    	'firstName[0]'=>'Aaron',
    	'lastName[0]'=>'Aaronson',
    	'email[0]'=>'aaaaaaaaaronson@fake-email.com',
    	'firstName[1]'=>'Alan',
    	'lastName[1]'=>'Aaronson',
    	'email[1]'=>'alanaaronson@fake-site.com'
    );
    $data = http_build_query($data); // encode and & delineate
    $method = 'PUT';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    // send the data
    curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$response = json_decode($response,true);
    else
    	$error = $code;
    											
  • DELETE None

Get, create or modify the notes that are stored about a lead.

  • GET

    Get notes for a lead.
    • primary request ID: leadID required The ID of a lead.
    • secondary request ID: noteID optional The ID of a lead's note.
    • additional input: none
    • output: Lead note information. If no note ID is sent all notes for the lead are returned. If a note ID is passed only the one note is returned.
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/note/1/1';
    $method = 'GET';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$response = json_decode($response,true);
    else
    	$error = $code;
    											
  • POST

    Update the notes information for one lead specified by the primary request ID.
    • primary request ID: leadID required The ID of a lead.
    • secondary request ID: noteID required The ID of a lead's note.
    • additional input: optional update fields in a URL encoded, ampersand delineated, query string format
    • output: If no POST data is supplied then a list of updatable fields with format information is returned
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/note/1/1';
    $data = array(
    	'note'=>'Loves almonds'
    );
    $data = http_build_query($data); // encode and & delineate
    $method = 'POST';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    // send the data
    curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$response = json_decode($response,true);
    else
    	$error = $code;
    											
  • PUT

    Create a new lead note.
    • primary request ID: leadID required The ID of a lead.
    • secondary request ID: none
    • additional input: optional update fields in a URL encoded, ampersand delineated, query string format
    • output: If a note is successfully created the new notes's ID will be returned. If no PUT data is supplied then a list of updatable fields with format information is returned
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/note/1';
    $data = array(
    	'note'=>'Smells like vanilla'
    );
    $data = http_build_query($data); // encode and & delineate
    $method = 'PUT';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    // send the data
    curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$response = json_decode($response,true);
    else
    	$error = $code;
    											
  • DELETE

    Remove a lead note.
    • primary request ID: leadID required The ID of a lead.
    • secondary request ID: noteID required The ID of the note to delete.
    • additional input: none
    • output: none (204 on success)
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/note/1/1';
    $method = 'DELETE';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$response = json_decode($response,true);
    else
    	$error = $code;
    											

Get, create or modify the saved properties (which power property updates) that are stored for a lead.

  • GET

    Get searches for a lead.
    • primary request ID: leadID required The ID of a lead.
    • secondary request ID: propertyID optional The ID of a lead's saved property.
    • additional input: none
    • output: If no property ID is passed all properties are returned. If a property ID is passed only the information for that specified property is returned.
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/property/1/1';
    $method = 'GET';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$response = json_decode($response,true);
    else
    	$error = $code;
    											
  • POST

    Update an existing lead's saved property.
    • primary request ID: leadID required The ID of a lead.
    • secondary request ID: propertyID required The ID of a lead's saved property.
    • additional input: optional update fields in a URL encoded, ampersand delineated, query string format
    • output: If no POST data is supplied then a list of updatable fields with format information is returned.
      • Note 1: the property query should be sent as an array. E.G.
        ...&property[idxID]=a001&property[listingID]=1234
      • Note 2: When seeing the list of updatable fields and reference to the size or maxlength of data are for display only. They represent rows and cols respectively and are not an indication of character limit.
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/property/1/1';
    $data = array(
    	'propertyName'=>'mansion',
    	'property'=>array('idxID'=>'a001','listingID'=>2345678)
    );
    $data = http_build_query($data); // encode and & delineate
    $method = 'POST';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    // send the data
    curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$response = json_decode($response,true);
    else
    	$error = $code;
    											
  • PUT

    Create a new lead saved property.
    • primary request ID: leadID required The ID of a lead.
    • secondary request ID: none
    • additional input: optional update fields in a URL encoded, ampersand delineated, query string format
    • output: If a saved property is successfully created the new property's ID will be returned.
      If no PUT data is supplied then a list of updatable fields with format information is returned.
      • Note 1: the property query should be sent as an array. E.G.
        ...&property[idxID]=a001&property[listingID]=1234
      • Note 2: When seeing the list of updatable fields and reference to the size or maxlength of data are for display only. They represent rows and cols respectively and are not an indication of character limit.
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/property/1';
    $data = array(
    	'propertyName'=>'ruins',
    	'property'=>array('idxID'=>'a001','listingID'=>345678)
    );
    $data = http_build_query($data); // encode and & delineate
    $method = 'PUT';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    // send the data
    curl_setopt($handle, CURLOPT_POSTFIELDS, $data);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$response = json_decode($response,true);
    else
    	$error = $code;
    											
  • DELETE

    Remove a lead saved property.
    • primary request ID: leadID required The ID of a lead.
    • secondary request ID: noteID required The ID of the property to delete.
    • additional input: none
    • output: none (204 on success)
    // access URL and request method
    $url = 'https://api.idxbroker.com/leads/property/1/1';
    $method = 'DELETE';
    
    // headers (required and optional)
    $headers = array(
    	'Content-Type: application/x-www-form-urlencoded', // required
    	'accesskey: abcdefghijklmnopqrstuvwx', // required - replace with your own
    	'outputtype: json' // optional - overrides the preferences in our API control page
    );
    
    // set up cURL
    $handle = curl_init();
    curl_setopt($handle, CURLOPT_URL, $url);
    curl_setopt($handle, CURLOPT_HTTPHEADER, $headers);
    curl_setopt($handle, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($handle, CURLOPT_SSL_VERIFYHOST, false);
    curl_setopt($handle, CURLOPT_SSL_VERIFYPEER, false);
    
    if ($method != 'GET')
    	curl_setopt($handle, CURLOPT_CUSTOMREQUEST, $method);
    
    // exec the cURL request and returned information. Store the returned HTTP code in $code for later reference
    $response = curl_exec($handle);
    $code = curl_getinfo($handle, CURLINFO_HTTP_CODE);
    
    if ($code >= 200 || $code < 300)
    	$response = json_decode($response,true);
    else
    	$error = $code;