1

海,任何人都可以帮助我......当我这样写时:

$file=file_get_contents('https://graph.facebook.com/me?access_token=1932993|twetrg|vsfgsewr');

代码也得到了很好的响应。

但是当我这样写时:

1. $tk='';
2. $tk='1932993|twetrg|vsfgsewr';//intialize the token value to variable
3. $file=file_get_contents('https://graph.facebook.com/me?access_token=$tk');

然后第 3 行显示警告为“未能打开流:HTTP 请求失败!”

请帮助我

4

1 回答 1

4

变量插值不会发生在单引号中。

所以使用双引号作为:

$file=file_get_contents("https://graph.facebook.com/me?access_token=$tk");

或者你可以这样做:

$file=file_get_contents('https://graph.facebook.com/me?access_token='.$tk);
于 2010-09-20T07:26:34.283 回答