嘿朋友我想通过php编辑这行,并希望只获得访问令牌它是如何工作的我真的不知道........提前谢谢 此处是我要编辑的行,仅在编辑
后才能获取访问令牌{"session_key":"5.Gdl_wBHvvGgqgg.1492451185.6-100009065037646","uid":100009065037646,"secret":"6ead07f9e86b834479ce5db2","access_token":"EAAAAAYsX7TsBAO1ciZAeWUDDvXGpgpI4DZCZBPFGbKHVxETEuniiRRyoyHQsgmSnbz3EL2QWLxGRK5Omhc6NL9VLkDxMZBIomIbKfFLZAqcy2ueillVrehoB3Sh95mcSalblAs0Pmj4PrcKZBZC1KVWJ0Hv2S1NDL2OTXR2Pp9vsUGEAFbpEaJ7GDTbQyDjy70hSp7wZDZD","machine_id":"cf_0WHKKYqcQK6mM0akSiy0P","confirmed":true,"identifier":"9472531429 "}
,这是我的php脚本,我想从中编辑此行,只获取访问令牌而不是整行
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;
答案 0 :(得分:0)
$line = '{"session_key":"5.Gdl_wBHvvGgqgg.1492451185.6-100009065037646","uid":100009065037646,"secret":"6ead07f9e86b834479ce5db2","access_token":"EAAAAAYsX7TsBAO1ciZAeWUDDvXGpgpI4DZCZBPFGbKHVxETEuniiRRyoyHQsgmSnbz3EL2QWLxGRK5Omhc6NL9VLkDxMZBIomIbKfFLZAqcy2ueillVrehoB3Sh95mcSalblAs0Pmj4PrcKZBZC1KVWJ0Hv2S1NDL2OTXR2Pp9vsUGEAFbpEaJ7GDTbQyDjy70hSp7wZDZD","machine_id":"cf_0WHKKYqcQK6mM0akSiy0P","confirmed":true,"identifier":"9472531429 "}';
$decoded = json_decode($line,true);
echo $decoded['access_token'];
此代码必须完成这项工作。根据您的情况,您不应该需要preg_match。