tinchorton

Members
  • Content Count

    2
  • Joined

  • Last visited


Reputation Activity

  1. Like
    tinchorton reacted to Adrian in Listado / Dump de Categorías   
    Dump de Categorias:
     
    try{
     
    // crear el archivo categoriesMLA.json.gzip con 777 en permisos    
    $fp = fopen("categoriesMLA.json.gzip", "w");
    $curl = curl_init();
    curl_setopt($curl, CURLOPT_URL, 'https://api.mercadolibre.com/sites/MLA/categories/all');
    curl_setopt($curl, CURLOPT_FILE, $fp);
    curl_setopt($curl, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 10); 
    curl_setopt($curl, CURLOPT_RETURNTRANSFER,1); 
    curl_setopt($curl, CURLOPT_TIMEOUT,60);
    curl_setopt($curl, CURLOPT_SSLVERSION , 1);
     
     
    $httpCode = curl_getinfo($curl, CURLINFO_HTTP_CODE);
    if($httpCode == 404) {        
    echo "algo pasó";
    }else
    {
    $contents = curl_exec($curl);
    if($contents!=false)
    {fwrite($fp, $contents);
    echo "se guardó con exito";
    }else{
    echo "vino vacío";
     
    }
    }
    curl_close ($curl);
    fclose($fp);
     
    } catch (Exception $e) {
      var_dump($e->getMessage());