1. Home
  2. /
  3. MFORMULA Catálogo Eletrônico
  4. /
  5. API
  6. /
  7. Clientes
  8. /
  9. Como adicionar clientes via...

Como adicionar clientes via API ?

POST: http://www.nomedoseusite.com.br/api_customers.php?action=add_customers

Parameter Format Description
customers_firstname JSON

Customers Firstname
Only text is required
Format: varchar(32)
* FIELD REQUIRED

customers_lastname JSON Customers Lastname
Only text is required
Format: varchar(32)
* FIELD REQUIRED
customers_email_address JSON E-mail address
Example: name@site.com.br
Format: varchar(96)
* FIELD REQUIRED
customers_password JSON Password
Minimum: 8 characters
Format: varchar(40)
* FIELD REQUIRED
customers_telephone JSON Telephone
Example: (11) 3230-6255
Format: varchar(32)
* FIELD REQUIRED
customers_telephone_commercial JSON Telephone Commercial
Example: (11) 3230-6255
Format: varchar(32)
customers_telephone_mobile JSON Telephone Mobile
Example: (11) 3230-6255
Format: varchar(32)
skype JSON Skype name
Format: varchar(32)
msn JSON MSN name
Format: varchar(32)
customers_fax JSON Telephone Fax
Example: (11) 3230-6255
Format: varchar(32)
customers_newsletter JSON Use the 1 to YES or 0 to NO
Only number is required
Format: int(1)
* FIELD REQUIRED
customers_groups_id JSON Check the API to get the list of customers groups
Only number is required
Format: int(11)
* FIELD REQUIRED
customers_language JSON

english, espanol, japanese or portugues
* FIELD REQUIRED

customers_gender JSON m or f
* FIELD REQUIRED
customers_dob JSON DD/MM/YYYY
* FIELD REQUIRED
entry_street_address JSON Street address
Format: varchar(64)
* FIELD REQUIRED
entry_number JSON Number Street Address
Only number is required
* FIELD REQUIRED
entry_completion JSON Completion Street Address
entry_suburb JSON Suburb
entry_postcode JSON Post Code
Only number is required
* FIELD REQUIRED
entry_city JSON City
Only text is required
* FIELD REQUIRED
entry_state JSON Check the API to get the list of State
* FIELD REQUIRED
entry_country_id JSON Check the API to get the list of Country
Only number is required
* FIELD REQUIRED
entry_rg JSON RG
entry_cpf JSON CPF
entry_company JSON Company Name
entry_cnpj JSON CNPJ
entry_ie JSON IE
person_kind JSON pj or pf
Format: varchar(2)
* FIELD REQUIRED

PHP Sample

 // sample add customers
 
 $url = $domain_url . '/api_customers.php?action=add_customers';

 $data = array("customers_firstname" => "Customers Firstname", // Customers Firstname * FIELD REQUIRED
 "customers_lastname" => "Customers Lastname", // Customers Lastname * FIELD REQUIRED
 "customers_email_address" => "email@mformula.com.br", // E-mail address * FIELD REQUIRED
 "customers_password" => "teste", // Password * FIELD REQUIRED
 "customers_telephone" => "(11) 3230-6255", // Telephone Example: (11) 3230-6255 * FIELD REQUIRED
 "customers_telephone_commercial" => "(11) 3230-6255", // Telephone Commercial Example: (11) 3230-6255
 "customers_telephone_mobile" => "(11) 3230-6255", // Telephone Mobile Example: (11) 3230-6255
 "skype" => "", // Skype name
 "msn" => "", // MSN
 "customers_fax" => "", // Telephone Fax Example: (11) 3230-6255
 "customers_newsletter" => "1", // Use the 1 to YES or 0 to NO (Only number is required) * FIELD REQUIRED
 "customers_groups_id" => "", // Check the API to get the list of customers groups (Only number is required) * FIELD REQUIRED
 "customers_language" => "portugues", // english, espanol, japanese or portugues * FIELD REQUIRED
 "customers_gender" => "m", // m or f * FIELD REQUIRED
 "customers_dob" => "01/02/1980", // DD/MM/YYYY * FIELD REQUIRED
 "entry_street_address" => "Av Paulista", // Street address * FIELD REQUIRED
 "entry_number" => "1500", // Number Street Address * FIELD REQUIRED
 "entry_completion" => "", // Completion Street Address
 "entry_suburb" => "Jardins", // Suburb
 "entry_postcode" => "04206000", // Post Code
 "entry_city" => "Sao Paulo", // City * FIELD REQUIRED
 "entry_state" => "Sao Paulo", // Check the API to get the list of State * FIELD REQUIRED
 "entry_country_id" => "30", // Check the API to get the list of Country (Only number is required) * FIELD REQUIRED
 "entry_rg" => "", // RG
 "entry_cpf" => "28240621856", // CPF
 "entry_company" => "", // Company Name
 "entry_cnpj" => "", // CNPJ
 "entry_ie" => "", // IE
 "person_kind" => "pf" // pj or pf * FIELD REQUIRED
 );
 
 $data_string = json_encode($data); 

 $ch = curl_init($url);
 curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 
 curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string); 
 curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
 curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); 
 curl_setopt($ch, CURLOPT_HTTPHEADER, array( 
 'Content-Type: application/json',
 "Cache-Control: no-cache", 
 'Usuario1: ' . base64_encode($usuario1),
 'Senha1: ' . base64_encode($senha1), 
 'Content-Length: ' . strlen($data_string)) 
 ); 
 
 $result = curl_exec($ch);
 curl_close($ch);

 print_r($result);
 
 // sample add customers eof

Return Error:

code
message

Return Success:

code
id
message

Deixe um comentário 0