| Server IP : 138.197.176.125 / Your IP : 216.73.217.122 Web Server : Apache/2.4.41 (Ubuntu) System : Linux SuiteCRM-8 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64 User : root ( 0) PHP Version : 8.3.19 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/googleoffice365SuiteTesting/ |
Upload File : |
<?php
// header
header("Content-Type:application/json");
include_once 'include/Webservices/Relation.php';
include_once 'vtlib/Vtiger/Module.php';
include_once 'includes/main/WebUI.php';
require_once('include/utils/utils.php');
global $adb,$current_user;
$jsonStr = file_get_contents("php://input"); //read the HTTP body.
$jsonDecodeData = json_decode($jsonStr, true);
$tokenDetails = json_decode($jsonDecodeData['token'],true);
$currentUserId = $jsonDecodeData['userId'];
$accessToken = $tokenDetails['access_token'];
$refreshToken = $tokenDetails['refresh_token'];
$expiresIn = $tokenDetails['expires_in'];
$currentTime = date('Y-m-d H:i:s');
$token = "'".$accessToken."'";
$refreshTokenData = "'".$refreshToken."'";
$expiresToken = "'".$expiresIn."'";
$date = "'".$currentTime."'";
$curl = curl_init();
curl_setopt_array($curl, array(
CURLOPT_URL => "https://graph.microsoft.com/v1.0/me",
CURLOPT_RETURNTRANSFER => true,
CURLOPT_ENCODING => "",
CURLOPT_MAXREDIRS => 10,
CURLOPT_TIMEOUT => 30,
CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
CURLOPT_CUSTOMREQUEST => "GET",
CURLOPT_POSTFIELDS => "",
CURLOPT_HTTPHEADER => array(
"Authorization: Bearer ".$accessToken
),
));
$response = curl_exec($curl);
$jsonDecodeData = json_decode($response, true);
$emailId = $jsonDecodeData['userPrincipalName'];
$usersEmailId = "'".$emailId."'";
$err = curl_error($curl);
$query2 = $adb->pquery("INSERT INTO `ctgoogleoffice365suite_ctoutlooksuitesync_token`(`user_id`, `token`,`refresh_token`,`token_generated_time`,`token_expires_in`,`users_emailid`) VALUES ($currentUserId, $token, $refreshTokenData, $date, $expiresToken, $usersEmailId)",array());
json_encode(array('status' => 'success'));
?>