failed to open stream: Redirection limit reached, aborting in
hatası alıyorum error_log'da
nasıl çözebilirim yardımcı olabilir misiniz?
Kod :
<?php
$app_id = 'SANSUR'; // your application app id
$app_secret = 'sansur'; //your application app secret
$code = $_GET['code']; // the GET parameter you got in the callback: http://yourdomain/?code=XXX
$context = stream_context_create(
array(
'http' => array(
'max_redirects' => 101
)
)
);
$get = file_get_contents("https://SANSUR.COM/authorize?app_id={$app_id}&app_secret={$app_secret}&code={$code}", false, $context);
curl_setopt($get, CURLOPT_URL, $get);
curl_setopt($get, CURLOPT_RETURNTRANSFER, true);
curl_setopt($get, CURLOPT_FOLLOWLOCATION, true);
$json = json_decode($get, true);
if (!empty($json['access_token'])) {
$access_token = $json['access_token']; // your access token
$type = "get_user_data"; // or posts_data
$get = file_get_contents("https://SANSUR.COM/app_api?access_token={$access_token}&type={$type}", false, $context);
header('Content-type:application/json;charset=utf-8');
$obj = json_decode($get);
$user_id = $obj->user_data->id;
$user_name = $obj->user_data->username;
$email = $obj->user_data->email;
$first_name = $obj->user_data->first_name;
$last_name = $obj->user_data->last_name;
$gender = $obj->user_data->gender;
$meetlink_access = $obj->user_data->meetlink_access;
if($meetlink_access == 0){
header('Location: https://auth.SANSUR.COM/hata/ML303');
die();
}else{
try {
$baglanti = new PDO("mysql:host=localhost;dbname=SANSUR", "SANSUR", "SANSUR");
$baglanti->exec("SET NAMES utf8");
$baglanti->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
$sorgu = $baglanti->prepare("SELECT * FROM users WHERE user_id = :user_id AND link_access = 1");
$sorgu->bindParam(':user_id', $user_id, PDO::PARAM_STR);
$sorgu->execute();
if(!$sorgu || $sorgu->rowCount() > 0){
ob_start();
session_start();
$_SESSION['valid'] = true;
$_SESSION['timeout'] = time();
$_SESSION['user_id'] = $user_id;
header('Location: https://link.SANSUR.COM/panel');
exit;
}else{
/* EĞER KAYITLI DEĞİLSE
$sorgu = $baglanti->prepare("INSERT INTO users(user_id, user_name, email, first_name, last_name, gender) VALUES(?, ?, ?, ?, ?, ?)");
$sorgu->bindParam(1, $user_id, PDO::PARAM_STR);
$sorgu->execute();
*/
ob_start();
session_start();
$_SESSION['valid'] = true;
$_SESSION['timeout'] = time();
$_SESSION['user_id'] = $user_id;
header('Location: https://link.SANSUR.COM/panel');
}
} catch (PDOException $e) {
die($e->getMessage());
}
$baglanti = null;
}
}
?>