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 YoloV5 第三方库的版本对照问题
  • ¥15 请完成下列相关问题!
  • ¥15 drone 推送镜像时候 purge: true 推送完毕后没有删除对应的镜像,手动拷贝到服务器执行结果正确在样才能让指令自动执行成功删除对应镜像,如何解决?
  • ¥15 求daily translation(DT)偏差订正方法的代码
  • ¥15 js调用html页面需要隐藏某个按钮
  • ¥15 ads仿真结果在圆图上是怎么读数的
  • ¥20 Cotex M3的调试和程序执行方式是什么样的?
  • ¥20 java项目连接sqlserver时报ssl相关错误
  • ¥15 一道python难题3
  • ¥15 牛顿斯科特系数表表示