
<center><h2><strong>Ubuntu</strong></h2>
­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­­
<!DOCTYPE html>
<html>
<?php
    session_start();
    error_reporting(E_ALL);
    ini_set("display_errors", 1);

    include_once ("./lib/gestion.lib.php");
    $ClassCdeV2 = new ClassCdeV2('prod');


//  pour API V2
    define("APIZOHO", [ "IdOrg"  => "650182655",                                  // Id organization
                        "IdCli"  => "1000.KL48ACSNU2NS34520ESYY3FWZUBS0E",        // Id client
                        "Secret" => "3b4a8173e9dbd396aaeb2603db7560f5ff9a323bb6", // Secret
        ]
    );


//  -----------------------------
// Lire une ticket
//$refresh_token = "1000.b6f3fbde292467fe8a557f62911c6247.9b5bf7cef94fee54313dc0878010f87e"; // Si l acces token change il faut changer ce code

$refresh_token = "1000.d744d0da612bdfeb2c3886974345d204.03bd4ba7a013233beddba67ef3b3439c"; // SEARCH
$Url           = "https://accounts.zoho.com/oauth/v2/token?refresh_token=$refresh_token&client_id=".APIZOHO['IdCli']."&client_secret=". APIZOHO['Secret']."&grant_type=refresh_token";
$Param         = ['url' => $Url, 'method' => 'POST'];
$Result        = $ClassCdeV2->MyCurl_APIZOHO_V2($Param);
$Result        = json_decode($Result, TRUE);
$Token         = "Zoho-oauthtoken " . $Result['access_token'];
echo "<h1>=>".$Token."</h1>";

$curl = curl_init();


//$URL = 'https://desk.zoho.com/api/v1/tickets/192475000028237814?include=contacts,products,assignee,departments,team';

//$URL ='https://desk.zoho.com/api/v1/tickets/search?ticketNumber=20676';
$URL ='https://desk.zoho.com/api/v1/tickets/search?subject=Nouvelle';


curl_setopt_array($curl, array(
    CURLOPT_URL => $URL,
    CURLOPT_RETURNTRANSFER => true,
    CURLOPT_ENCODING => '',
    CURLOPT_MAXREDIRS => 10,
    CURLOPT_TIMEOUT => 0,
    CURLOPT_FOLLOWLOCATION => true,
    CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
    CURLOPT_CUSTOMREQUEST => 'GET',
    CURLOPT_HTTPHEADER => array(
        'Authorization: '.$Token
    ),
));

$response = curl_exec($curl);
// Array
    echo "<pre>"; print_r($response); echo "</pre>";
curl_close($curl);

$json = json_decode($response,TRUE);

// Array
    echo "<pre>"; print_r($json); echo "</pre>";




?>