Sending 1 jSON at a time for API

1

Hello. I have a question that I can not heal. I'm doing a PHP integration of Opencart with the Your Sales API, but the API only accepts 1 json at a time to register, ie I need to get it sent one, then the other and so it goes, but I'm not sure how to do it .

The code is this:

<?php
/* Integração de Opencart 1.5.6.4 com SuasVendas
* Desenvolvedor Raphael Cordeiro
*/

/* error_reporting(0);
*ini_set("display_errors", "0"); */
require_once ("config.php");
require_once (DIR_SYSTEM . "startup.php");

$apikey ="put-your-key-here";
$url = "https://api.suasvendas.com/api/Colaborador";
$retorno = executePostSellers($url, $apikey);

/*Consulta e envia os dados dos clientes do Opencart para a API do SuasVendas */

function executePostSellers($url){
    $db = new DB(DB_DRIVER, DB_HOSTNAME, DB_USERNAME, DB_PASSWORD, DB_DATABASE);
    $query = $db->query("SELECT * FROM '" . DB_PREFIX . "affiliate' WHERE approved = '1'");
    if ($query->num_rows) {
      foreach ($query->rows as $row) {
        $header[] = array("cola_id" => $row['affiliate_id'],
        "cola_tipo" => "VENDEDOR",
        "cola_nome" => $row["firstname"].$row["lastname"],
        "cola_status" => "Ativo",
        "cola_cont_id" => "130",
        "cola_telefone" => $row["telephone"],
        "cola_email" => $row["email"],
        "cola_senha" => "123mudar");
      }
    }

    $header_string = json_encode($header);

    $header[] = "Authorization: Bearer put-your-key-here";
    $header[] = 'Content-Type: application/json';
    $ch = curl_init("https://api.suasvendas.com/api/Colaborador");
    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
    curl_setopt($ch, CURLOPT_POST, true);
    curl_setopt($ch, CURLOPT_POSTFIELDS, $header_string);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    $response = curl_exec($ch);
    curl_close($ch);
    return var_dump($header_string);
}

How can I get 1 json to be sent at a time?

    
asked by anonymous 31.10.2017 / 22:23

0 answers