इसलिए मैंने quickstart मार्गदर्शिका का पालन किया और शेड्यूलर नामक कक्षा में इसे तोड़ने का फैसला किया। मैं प्रमाणीकरण कोड पर काम कर रहा हूं, लेकिन मुझे यह मिल रहा है: "त्रुटि 400 (OAuth 2 त्रुटि) त्रुटि अमान्य अनुरोध गुम आवश्यक पैरामीटर: redirect_uri"।Google क्लाइंट एपीआई - गुम होने की आवश्यकता पैरामीटर: redirect_uri
class scheduler{
//The Google Client object
private $googleClient;
//the Google Calendar Service ojbect
private $calendarService;
/*
* Google Calendar Setup
*
* This creates a Google Client object so that you may create a Google Calendar object.
*
*/
function __construct(){
//set the application name
define("APPLICATION_NAME", "Web client 1");
//
define("CREDENTIALS_PATH", "~/scheduler/credentials.json");
//
define("CLIENT_SECRET_PATH", __DIR__ . "/scheduler/client_secret.json");
//
define("SCOPES", implode(" ", array(Google_Service_Calendar::CALENDAR_READONLY)));
/*if(php_sapi_name() != "cli"){
throw new Exception("This application must be run on the command line");
}*/
//create the google client
$this->googleClient = new Google_Client();
//setup the client
$this->googleClient->setApplicationName(APPLICATION_NAME);
$this->googleClient->setDeveloperKey("AIzaSyBmJLvNdMYuFhVpWalkUdyStrEBoVEayYM");
$this->googleClient->setScopes(SCOPES);
$this->googleClient->setAuthConfigFile(CLIENT_SECRET_PATH);
$this->googleClient->setAccessType("offline");
//get the credentials file path
$credentialsPath = expandHomeDirectory(CREDENTIALS_PATH);
//if the file exists
if(file_exists($credentialsPath)){
//get the credentials from the file
$accessToken = file_get_contents($credentialsPath);
}//if it does not
else{
//request the authorization url
$authURL = $this->googleClient->createAuthUrl();
//print the authorization ulr
echo "<a href=\"$authURL\">Press Me</a><br /><br />";
//prompt the user to enter the auth code
print("Enter authentication code: ");
//
$authCode = trim(fgets(STDIN));
//exchange authorization for an access token
$accessToken = $this->googleClient->authenticate($authCode);
//store credentials to disk
if(!file_exists(dirname($credentialsPath))){
mkdir(dirname($credentialsPath), 0700, true);
}
//put the contents into the credential files
file_put_contents($credentialsPath, $accessToken);
}
$this->googleClient->setAccessToken($accessToken);
//refresh token if its expired
if($this->googleClient->isAccessTokenExpired()){
$this->googleClient->refreshToken($client->getRefreshToken());
file_put_contents($credentialsPath, $this->googleClient->getAccessToken());
}
}
मुझे समस्या में कोई समाधान नहीं मिला समस्या का कारण मिला। मेरे Google डेवलपर कंसोल के तहत मैंने प्राधिकृत रीडायरेक्ट यूआरआई अनुभाग में "http://localhost/" डालने का प्रयास किया। यह मुझे यह त्रुटि देता है "क्षमा करें, एक समस्या है। अगर आपने जानकारी दर्ज की है, तो इसे जांचें और पुनः प्रयास करें। अन्यथा, समस्या स्वयं ही स्पष्ट हो सकती है, इसलिए बाद में जांचें।" क्या स्थानीय डेवलपर सर्वर के रीडायरेक्ट यूरी को स्वीकार करने के लिए Google डेवलपर कंसोल बनाने का कोई तरीका है?
किसी की मदद करने के लिए तैयार? –