views:

36

answers:

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

+4  A: 

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
As a side note, line 1 in the OP is not necessary.
Peter Ajtai