| Server IP : 103.234.187.230 / Your IP : 216.73.216.216 Web Server : Apache System : Linux lserver42043-ind.megavelocity.net 3.10.0-1160.108.1.el7.x86_64 #1 SMP Thu Jan 25 16:17:31 UTC 2024 x86_64 User : apache ( 48) PHP Version : 7.4.33 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /var/www/html/b2bzend/application/controllers/ |
Upload File : |
<?php
class WhatsappTokenController extends Catabatic_ValidateGtx {
public $AgencySysId;
public $IsAutoProposalOnFBLead;
public $fModel;
public $getSiteUrl;
public function init() {
parent::init();
$this->AgencySysId = Travel_Model_AgencyAuth::getIdentity()->AgencySysId;
$this->IsAutoProposalOnFBLead = Travel_Model_AgencyAuth::getIdentity()->IsAutoProposalOnFBLead;
$this->fModel = new Finance_Model_Finance();
$this->getSiteUrl = Catabatic_Helper::getSiteUrl();
}
public function indexAction() {
$url = "https://www.facebook.com/v17.0/dialog/oauth?response_type=code&client_id=280236861344884&redirect_uri=https://globaltravelexchange.com/facebook-lead/get-access-key&state=87587289237984777&scope=public_profile,email,whatsapp_business_management,whatsapp_business_messaging";
header("Location:$url");
exit;
}
public function sendRequest($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HEADER, 0);
if (!empty($_SERVER['HTTPS']) && $_SERVER['HTTPS'] != 'off') {
curl_setopt($ch, CURLOPT_PORT, 443);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);
}
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$output = curl_exec($ch);
curl_close($ch);
return $output;
}
public function getAccessKeyAction() {
if (isset($_REQUEST) && (isset($_REQUEST['code']) && $_REQUEST['code'] != "")) {
$accessCode = $_REQUEST['code'];
$this->view->pageName = array();
$url = "https://graph.facebook.com/v15.0/oauth/access_token?code=$accessCode&client_id=280236861344884&redirect_uri=" . $this->getSiteUrl . "facebook-lead/get-access-key&client_secret=185ab544ad959002f33e3928f6c5d53c";
$reponseVal = $this->sendRequest($url);
echo "<pre>";print_r($reponseVal);exit;
}
}
public function fbExchangeToken($accessToken) {
$fbExchangeTokenUrl = "https://graph.facebook.com/v15.0/oauth/access_token?grant_type=fb_exchange_token&client_id=280236861344884&client_secret=185ab544ad959002f33e3928f6c5d53c&fb_exchange_token=$accessToken";
$fbExchangeTokenArray = $this->sendRequest($fbExchangeTokenUrl);
return $fbExchangeTokenArray;
}
}