I have a national and international travel agency, and i have a db with so many passengers and important information. So I want to do a backup of that db everytime I save a new one. So my idea was upload the backup file to my Dropbox account when I click on save button. I could make backup load successfully, but the problem is that whenever I want to upload a new backup, ask me a token code acces when used, expires. What I need is to skip this step or put automatically the token acces code without redirect.
Is there any solution ? So many thanks for your time. Greetings!
Here is my code of my backup.php:
<?php
$fecha = date("d") . "-" . date("m") . "-" . date("Y");
exec('mysqldump --user=taiyovia_admin --password=50095009 --host=localhost --databases taiyovia_pax taiyovia_usuario taiyovia_rooming > backup/'.$fecha.'.sql');
# Include the Dropbox SDK libraries
require_once "Dropbox/lib/Dropbox/autoload.php";
use \Dropbox as dbx;
$json = "app.json";
$appInfo = dbx\AppInfo::loadFromJsonFile($json);
$webAuth = new dbx\WebAuthNoRedirect($appInfo, "PHP-Example/1.0");
$authorizeUrl = $webAuth->start();
echo "1. Go to: " . $authorizeUrl . "
";
echo "2. Click \"Allow\" (you might have to log in first).
";
echo "3. Copy the authorization code.
";
$authCode ="HERE IS WHERE I PUT THE ACCES TOKEN CODE TO UPLOAD THE FILE";
list($accessToken, $dropboxUserId) = $webAuth->finish($authCode);
print "Access Token: " . $accessToken . "
";
$dbxClient = new dbx\Client($accessToken, "PHP-Example/1.0");
$accountInfo = $dbxClient->getAccountInfo();
print_r($accountInfo);
$f = fopen("backup/".$fecha.".sql", "rb");
$result = $dbxClient->uploadFile("/".$fecha.".sql", dbx\WriteMode::add(), $f);
fclose($f);
print_r($result);
$folderMetadata = $dbxClient->getMetadataWithChildren("/");
print_r($folderMetadata);
$f = fopen("backup/".$fecha.".sql", "w+b");
$fileMetadata = $dbxClient->getFile("/".$fecha.".sql", $f);
fclose($f);
print_r($fileMetadata);
</div>