아주 간단한 웹 애플리케이션을 구축 중입니다. 사용자가 Instagram으로 로그인 한 후 코드 반환을 처리하는 데 문제가 있습니다. 또한 다른 API를 사용하여 여기에서 찾을 수 있도록 도와 드리겠습니다 : https://github.com/cosenary/Instagram-PHP-API.Instagram API로 사용자 인증 처리하기
내 홈페이지 그들이 내 응용 프로그램에 권한을 부여하고 인스 타 그램이 http://your-redirect-uri?code=CODE
에 응답 할 때 이
<?php
require 'Instagram.php';
use MetzWeb\Instagram\Instagram;
// initialize class
$instagram = new Instagram(array(
'apiKey' => 'YOUR_APP_KEY',
'apiSecret' => 'YOUR_APP_SECRET',
'apiCallback' => 'YOUR_APP_CALLBACK' // must point to success.php
));
// create login URL
$loginUrl = $instagram->getLoginUrl();
?>
이
사용자가 성공적으로 인스 타 그램 로그인 페이지로 전송됩니다 하지만이 다음 페이지에 실패
당신의 사용자가 아래의 PHP 코드를 볼 수 기록 세우다.아래에 표시되어야하는 "성공"페이지의 코드를 볼 수 있습니다.
/**
* Instagram PHP API
*
* @link https://github.com/cosenary/Instagram-PHP-API
* @author Christian Metz
* @since 01.10.2013
*/
require_once 'Instagram.php';
use MetzWeb\Instagram\Instagram;
// initialize class
$instagram = new Instagram(array(
'apiKey' => 'YOUR_APP_KEY',
'apiSecret' => 'YOUR_APP_SECRET',
'apiCallback' => 'YOUR_APP_CALLBACK' // must point to success.php
));
// receive OAuth code parameter
$code = $_GET['code'];
// check whether the user has granted access
if (isset($code)) {
// receive OAuth token object
$data = $instagram->getOAuthToken($code);
$username = $username = $data->user->username;
// store user access token
$instagram->setAccessToken($data);
// now you have access to all authenticated user methods
$result = $instagram->getUserMedia();
} else {
// check whether an error occurred
if (isset($_GET['error'])) {
echo 'An error occurred: ' . $_GET['error_description'];
}
}
?>
사용자가 인증 요청을 취소하면 "성공"페이지가 올바르게 렌더링되고 올바른 오류 메시지가 표시됩니다. 그래서 내 문제는 Instagram 내 웹 응용 프로그램에 반환 코드 매개 변수를 처리하는 것입니다 믿습니다. 도와 주셔서 감사합니다.