doubiankang2845 2017-06-10 15:50
浏览 13
已采纳

只获取特定代码

In my site user get their own secret code with access token and submit That code in my site and from this all code I only want to take access token with the help of php... Check this ScreenShootss.jpg

Example of access token {"session_key":"5.TVJlCXvhgqdhpA.1497109242.26-100007001746590","uid":100007001746590,"secret":"80cc3dc2ba89e635dcf84b41d6efcc38","access_token":"EAAAAAYsX7TsBAEa6qMaCj1qCgnOKFHBcfu76C6PrUdK1LnIh39jmabZAdVWmQLO3Ol64ZCXY4388DBfUwksxONGXE5dUY0mK9M07aszl5Qvs8ccqQ39xLEsK2gc1RUJQ0Kqy1ror7R8EPHZCX6pOzX0o4oQAJ1kOq8Oz0n0GysK64ebCsDEokwG36j1awnYaDoJPvOn2AZDZD","machine_id":"-hI8WaLcNeEVUSPuxcEpmhQU","confirmed":true}

And I also try to separate access token by separating all this code but this actually not working

Here is my php script

if(isset($_POST['submit'])) {
    $token2 = $_POST['token'];
    if(preg_match("'access_token=(.*?)&expires_in='", $token2, $matches)){
        $token = $matches[1];
            }
    else{
        $token = $token2;
    }
        $extend = get_html("https://graph.facebook.com/me/permissions?access_token="  . $token);

How to do this and thanks in advance

  • 写回答

2条回答 默认 最新

  • doumi1944 2017-06-10 16:09
    关注

    You can use this code to get only access_token from JSON code

    if(isset($_POST['submit'])) {
        $token2 = $_POST['token'];
        $obj = json_decode($token2);
        echo "Access Token is: <br />". $obj->{'access_token'}; // You can remove it or use this value
        $token = $obj->{'access_token'};
        $extend = get_html("https://graph.facebook.com/me/permissions?access_token="  . $token);
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 宇视监控服务器无法登录
  • ¥15 PADS Logic 原理图
  • ¥15 PADS Logic 图标
  • ¥15 电脑和power bi环境都是英文如何将日期层次结构转换成英文
  • ¥15 DruidDataSource一直closing
  • ¥20 气象站点数据求取中~
  • ¥15 如何获取APP内弹出的网址链接
  • ¥15 wifi 图标不见了 不知道怎么办 上不了网 变成小地球了
  • ¥50 STM32单片机传感器读取错误
  • ¥50 power BI 从Mysql服务器导入数据,但连接进去后显示表无数据