https://www.r10.net/google-servisler...ari-cekme.html Buradaki konumda Google Haritalardaki yorumları nasıl web sitemizde gösterebiliriz bunu araştırıyordum.
Bu API kullanmak için öncelikle başvuru yapmanız gerekiyor. Birkaç gün sonrada e-postanıza gelen maili cevaplamanız gerekiyor. Sonrasında onaylanırsa API, Google API kütüphanesinde açılıyor ve aktif edip kullanmaya başlıyorsunuz. Buraya kadar her şey okey.
Gelelim kullanmaya, Google API larına pek hakim olmadığım için alışma sürecinden sonra API a bağlanabildim fakat bir izin hatası alıyorum. Daha önce Google API'ları ile çalışmış kişiler varsa çözebileceğini düşünüyorum. Kodları aşağıda paylaşıyorum, kaçırdığım bir şey var muhtemelen ama bulamadım. Fikri olan, tecrübesi olan paylaşırsa sevinirim, API kullanacak olan arkadaşlar için de bu sorunla karşılaşırlarsa rehber niteliğinde bir konu olur.
API Döküman Linki: https://developers.google.com/my-bus...ntent/overview
Not: Ücretli destekte alabilirim.
PHP Kodu
<?php
defined('BASEPATH') or exit('No direct script access allowed');
require_once dirname(__FILE__) . '/google-client/vendor/autoload.php';
require_once dirname(__FILE__) . '/google-client/src/MyBusiness.php';
class GoogleApi
{
public $credentials;
public function __construct()
{
$this->credentials = dirname(__FILE__) . '/google-client/test.json';
}
public function get_reviews($data = [])
{
$client = new Google_Client();
$client->setAuthConfig($this->credentials);
$client->addScope(["https://www.googleapis.com/auth/plus.business.manage", "https://www.googleapis.com/auth/business.manage"]);
$mybusinessService = new Google_Service_MyBusiness($client);
$accounts = $mybusinessService->accounts;
$accountsList = $accounts->listAccounts()->getAccounts();
echo "<pre>";
print_r($accountsList);
}
}Response{ "error": { "code": 401, "message": "Request is missing required authentication credential. Expected OAuth 2 access token, login cookie or other valid authentication credential. See https://developers.google.com/identity/sign-in/web/devconsole-project.", "errors": [ { "message": "Login Required.", "domain": "global", "reason": "required", "location": "Authorization", "locationType": "header" } ], "status": "UNAUTHENTICATED", "details": [ { "@type": "type.googleapis.com/google.rpc.ErrorInfo", "reason": "CREDENTIALS_MISSING", "domain": "googleapis.com", "metadata": { "service": "mybusiness.googleapis.com", "method": "google.mybusiness.v4.Accounts.ListAccounts" } } ] } }