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 metadata提取的PDF元数据,如何转换为一个Excel
  • ¥15 关于arduino编程toCharArray()函数的使用
  • ¥100 vc++混合CEF采用CLR方式编译报错
  • ¥15 coze 的插件输入飞书多维表格 app_token 后一直显示错误,如何解决?
  • ¥15 vite+vue3+plyr播放本地public文件夹下视频无法加载
  • ¥15 c#逐行读取txt文本,但是每一行里面数据之间空格数量不同
  • ¥50 如何openEuler 22.03上安装配置drbd
  • ¥20 ING91680C BLE5.3 芯片怎么实现串口收发数据
  • ¥15 无线连接树莓派,无法执行update,如何解决?(相关搜索:软件下载)
  • ¥15 Windows11, backspace, enter, space键失灵