Проблема аутентификации с foursquare с использованием PHP - PullRequest
0 голосов
/ 07 апреля 2011

я использовал foursquare-async библиотеку с php для подключения к четырем квадратам.У меня есть два файла index.php и callback.php.На моей странице index.php код

<?php
require_once 'EpiCurl.php';
require_once 'EpiFoursquare.php';
$clientId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$clientSecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$redirectUrl='http://www.example.com/match/4square/callback.php';
$fsObj = new EpiFoursquare($clientId, $clientSecret);
  // $redirectUrl is what you specified when creating the application
  $url = $fsObj->getAuthorizeUrl($redirectUrl);
  echo "<a href=\"$url}\">Click here";
  ?>
И на моей странице callback.php код
<code><?php 
require_once 'EpiCurl.php';
require_once 'EpiFoursquare.php';
$clientId = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$clientSecret = 'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx';
$redirectUrl='http://www.example.com/match/4square/callback.php';
$fsObj = new EpiFoursquare($clientId, $clientSecret);
  // exchange the request token for an access token
  $token = $fsObj->getAccessToken($_GET['code'], $redirectUrl);
  // you can store $token->access_token in your database
  $fsObj->setAccessToken($token->access_token);
  $fsObj->setAccessToken($token->access_token);
  $badges = $fsObj->get('/users/self/badges');
  echo "<pre>";
print_r($badges);
echo "
";?> 1: когда я захожу из foursquare и запускаю приложение, оно перенаправляет меня на эту страницу с ошибкой
http://www.example.com/match/4square/callback.php%7D?code=xxxxxxxxxxxxxxxxxxxxxxxxx
Примечание: Посмотрите на% & D (это близкая фигурная скобка '}') после callback.php.Это генерирует ошибку
The requested URL /match/4square/callback.php} was not found on this server.
Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
2: когда я снимаю фигурную скобку, возникает ошибка
Fatal error: Uncaught exception 'EpiFoursquareBadRequestException' <br />with message '{ "error":"invalid_grant" }' in <br/>/home/cpantryc/public_html/match/4square/EpiFoursquare.php:244 Stack trace:<br /> #0 /home/cpantryc/public_html/match/4square/EpiFoursquare.php(208): <br />EpiFoursquareException::raise(Object(EpiCurlManager), false) #1 <br />/home/cpantryc/public_html/match/4square/callback.php(14): EpiFoursquareJson-><br />__get('access_token') #2 {main} thrown in <br />/home/cpantryc/public_html/match/4square/EpiFoursquare.php on line 244

Мой вопрос, что происходит не так.

...