cancel
Showing results for 
Search instead for 
Did you mean: 

How to achieve set Google Business Reviews Authorization Bearer Token?

How to achieve set Google Business Reviews Authorization Bearer Token?

Screenshot : https://i.stack.imgur.com/8mL25.png

 

I am using Google Business Review API, every time i manually copy and paste the token,

Screenshot : https://i.stack.imgur.com/EkVWi.png

 

how to refresh automatically,

My code :

<?php
namespace Zero\Storelocator\Block;

class Customerreview extends \Magento\Framework\View\Element\Template
{
public function __construct(\Amasty\Storelocator\Block\view\Attributes $attributes,
\Magento\Framework\View\Element\Template\Context $context,
\Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig,
array $data = []) {
$this->_attributes = $attributes;
$this->scopeConfig = $scopeConfig;
parent::__construct($context, $data);
}

protected function _prepareLayout(){
parent::_prepareLayout();

}

public function getCustomerReview(){

//Here you need to check system.xml file and get section_id/group_id/field_id
$authentication = $this->scopeConfig->getValue('customerreview/general/review_auth', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);

$accountId = $this->scopeConfig->getValue('customerreview/general/review_account_id', \Magento\Store\Model\ScopeInterface::SCOPE_STORE);

$authorization = "Authorization:".$authentication;
$url = 'https://mybusiness.googleapis.com/v4/accounts/'.$accountId.'/locations/45545454545454545454545/reviews';

$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json' , $authorization ));
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_TIMEOUT, 10);
$output = curl_exec($ch);

$writer = new \Zend\Log\Writer\Stream(BP . '/var/log/output.log');
$logger = new \Zend\Log\Logger();
$logger->addWriter($writer);
$logger->info(print_r('line no:42'. $output, true));

$allData = json_decode($output, TRUE); // You will get all the data

return $allData;

}

public function getCustomAttributes(){
if ($this->_attributes->getLocationAttributes()) {
return '';
}
return $this->_attributes->getLocationAttributes();
}
}

 

 

 

1 REPLY 1

Re: How to achieve set Google Business Reviews Authorization Bearer Token?

Unlocking the full potential of Google Business Reviews can significantly impact your online presence and reputation. To gain access and manage your reviews effectively, understanding how to set up an Authorization Bearer Token is crucial. This token acts as a secure authentication method, granting you the necessary permissions to interact with Google's API and retrieve valuable review data.In the digital world, language proficiency is essential for seamless communication and understanding technical documentation. You can also click here to flixfox apk download now