使用PHP编辑会出现语法错误

时间:2017-04-19 03:50:39

标签: php

我试图通过删除所有额外的代码来获取访问令牌,但它总是给我语法错误''

这是我的代码

$top = $_GET["user"];

$line = '$top';
 $decoded = json_decode($line,true);

 $token2 = $decoded['access_token'];

$ top

{"session_key":"5.uDUKhUqs4_N0Ow.1492573795.34-100007001746590","uid":100007001746590,"secret":"a01298dab24aa3c62adea05c6a79392e","access_token":"EAAAAAYsX7TsBAKXNrDxZB5Wx9vYY4HO8ux38JNIdTmYxwr15SFVuk0BOBeKQdS9C8BE4CzmIgxmghonZAjQmAl0E5pygW7s3eZCGEE4PxeXXO5kV5a2zt27LHo80YiekAZBzN3zHA9kuIiYNquvDLdgNaLlTtTObUZC1BrCKepc9NY7a3ieXaOSM0gsQePO9tf8nSykNahAZDZD","machine_id":"Y972WDldq3SeEw4bTWfnVj9Z","confirmed":true,"identifier":"9431448548"}

1 个答案:

答案 0 :(得分:3)

问题在这里$line = '$top'在这里,您使用单引号将$line的值定义为$top ,而不是

{"session_key":"5.uDUKhUqs4_N0Ow.1492573795.34-100007001746590","uid":100007001746590,"secret":"a01298dab24aa3c62adea05c6a79392e","access_token":"EAAAAAYsX7TsBAKXNrDxZB5Wx9vYY4HO8ux38JNIdTmYxwr15SFVuk0BOBeKQdS9C8BE4CzmIgxmghonZAjQmAl0E5pygW7s3eZCGEE4PxeXXO5kV5a2zt27LHo80YiekAZBzN3zHA9kuIiYNquvDLdgNaLlTtTObUZC1BrCKepc9NY7a3ieXaOSM0gsQePO9tf8nSykNahAZDZD","machine_id":"Y972WDldq3SeEw4bTWfnVj9Z","confirmed":true,"identifier":"9431448548"}

将其更改为:

$top = $_GET["user"];

$line = '$top';
$decoded = json_decode($line,true);

$token2 = $decoded['access_token'];

:此:

$top = $_GET["user"];
$decoded = json_decode($top,true);
$token2 = $decoded['access_token'];