Я работаю над интеграцией Google Plus с php, но всякий раз, когда я нажимаю "mydomainname.com/example.php", я получаю следующее сообщение error_get_last
"400. Это ошибка. Ошибка:redirect_uri_mismatch ",
В разделе авторизованного URI-адреса перенаправления консоли Google я вставил следующий URL myurl / google-plus / example.php
Вот мой код файла example.php, где яя не прав?
<code><?php
/* Require library */
require_once 'class.googleplus.php';
/* Configuration Values */
$config['consumer_key'] = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxx.apps.googleusercontent.com';
$config['consumer_secret'] = 'xxxxxxxxxxxxxxxxx';
$config['callbackUrl'] = 'http://' . $_SERVER['SERVER_NAME'] . '?verify';
$GooglePlus = new GooglePlusPHP($config);
/* Verification phase */
if (!isset($_SESSION['googlePlusOAuth']) && isset($_GET['verify']) && isset($_GET['code'])):
try {
unset($_SESSION['googlePlusOAuth']);
$accessToken = $GooglePlus->getAccessToken($_GET['code']);
$GooglePlus->setOAuthToken($accessToken->access_token, false);
$_SESSION['googlePlusOAuth'] = $accessToken;
} catch (Exception $e) {
die($e->getMessage());
exit;
}
header('Location: example.php');
exit;
endif;
/* No token, and no ?verify . Redirect to auth. */
if (!isset($_SESSION['googlePlusOAuth'])):
header('Location: ' . $GooglePlus->getAuthorizationUrl() );
endif;
/* Set Access Token */
$GooglePlus->setOAuthToken($_SESSION['googlePlusOAuth']['access_token']);
if (!$GooglePlus->testAuth())
die('Your token probably expired, or was not valid. Clear the session and try again.');
/* Profile */
$profile = $GooglePlus->getMyProfile();
/* My Activities */
$activities = $GooglePlus->getMyActivities();
/* People Search */
if (isset($_GET['search'])):
if (isset($_GET['search_pagetoken'])):
$search_pagetoken = $_GET['search_pagetoken'];
else:
$search_pagetoken = null;
endif;
$search_results = $GooglePlus->searchPeople($_GET['search'], $search_pagetoken);
endif;
/* Load Profile, override $activities */
if (isset($_GET['profile_id'])):
$profile_id = $_GET['profile_id'];
if (!is_numeric($profile_id)): continue; endif;
$activities = $GooglePlus->getPublicActivities($profile_id);
$user_profile = $GooglePlus->getUserProfile($profile_id);
endif;
?>
<html>
<head>
<title>Sample Google+</title>
</head>
<body>
<h1>Google+ Example Script</h1>
<h2>$profile</h2>
<pre><?php var_dump($profile); ?>
$ search_results
Установите $ _GET ['search'] для просмотра результатов.
<?php var_dump($search_results); ?>
$ user_profile
Установите $ _GET ['profile_id'] для просмотра результатов.
<?php var_dump($user_profile); ?>
$ деятельность
<?php var_dump($activities); ?>