1

Hai, can anyone help me... When I write like:

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

the code gets response as well good.

but when I write like:

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');

then the Line 3. display warning as "failed to open stream: HTTP request failed! "

kindly help me

Peter Ajtai
  • 56,972
  • 13
  • 121
  • 140
JAMES
  • 11
  • 1

1 Answers1

4

Variable interpolation does not happen in single quotes.

So use double quotes as:

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

Or you can do:

$file=file_get_contents('https://graph.facebook.com/me?access_token='.$tk);
codaddict
  • 445,704
  • 82
  • 492
  • 529