PHP | How to update backoffice colors & logo for all active clients in your reseller console

Publié presque 2 ans il y a par  Angélique Bernardo

Publier un sujet
A
Angélique Bernardo Administrateur

This scripts can be useful to re-apply default colors, your brand logo as well as profile's features & limitations:


<?php 
$apiKey = "";
$ssoToken = "";
$logoUrl = "https://yourdomainname/yourlogourl.png";

$dataColor = file_get_contents("https://api.agendize.com/api/2.0/resellers/settings/whiteLabel?apiKey=$apiKey&token=$ssoToken");

//fetch colors from the reseller settings
$reselleColor = json_decode($dataColor);
$colorHeader = "";
$colorMenu = "";
if ($reselleColor != null) {
    $colorHeader = $reselleColor->headerBackgroundColor;
    $colorMenu = $reselleColor->menuBackgroundColor;
    echo "Menu: " . $colorMenu . "\tHeader: " . $colorHeader . "\n";
} else {
    die();
}

//fetch list of all clients from the reseller console
$data = file_get_contents("https://api.agendize.com/api/2.0/resellers/accounts?apiKey=$apiKey&token=$ssoToken");
$clients = json_decode($data);

foreach ($clients->items as $client) {
    if ($client->status == "enabled") {
        echo $client->id. "\t" . $client->email . "\t";
        if (isset($client->profile)) {
            echo $client->profile->id . "\n";

            //create a new cURL resource
            $ch = curl_init("https://api.agendize.com/api/2.0/resellers/accounts/$client->id?apiKey=$apiKey&token=$ssoToken");

            //setup request to send json via POST
            $data = array(
                'whiteLabel' => array(
                    "headerBackgroundColor" => $colorHeader,
                    "menuBackgroundColor" => $colorMenu,
                    "logoURL" => $logoUrl
                ),
                'profile' => array(
                    "id" => $client->profile->id
                )
            );
            $payload = json_encode($data);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            //set the content type to application/json
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

            //execute the POST request
            $result = curl_exec($ch);

            //close cURL resource
            curl_close($ch);
            //create a new cURL resource
            $ch = curl_init("https://api.agendize.com/api/2.0/resellers/accounts/$client->id?apiKey=$apiKey&token=$ssoToken");

            //setup request to send json via POST
            $data = array(
                'whiteLabel' => array(
                    "headerBackgroundColor" => $colorHeader,
                    "menuBackgroundColor" => $colorMenu,
                    "logoURL" => $logoUrl
                ),
                'profile' => array(
                    "id" => $client->profile->id
                )
            );
            $payload = json_encode($data);
            curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
            curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PUT');
            curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

            //set the content type to application/json
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type:application/json'));

            //execute the POST request
            $result = curl_exec($ch);

            //close cURL resource
            curl_close($ch);
        } else {
            echo "No profile ID\n";
        }
    }
}
?>


0 Votes


0 Commentaires

Connexion ou S'inscrire pour poster un commentaire