开发者

Possible to access users name without granting access to application? Facebook. PHP

I'm building a facebook app for a client. They want to greet the current user by name. I was under the impression that this was possible without the user granting access as it is public data but I can't seem to get it to work without.

Having the user grant access to the app seems a little long winded just to greet them.

I'm using the PHP sdk.

Here is the app: http://www.facebook.com/pages/Why-Digital-Media/163519223704680?sk=app_271013792913122

Here is the code that should display the name:

<?php if ($user): ?>
    <?php $username = $user_profile['name']; ?>
      <?php echo "<span id=\"welcome\" title=\"Hi $us开发者_运维问答ername\" id='caption_span'>Hi $username</span>" ?> 
      <?php else: ?>
      <?php  echo "<span title=\"Hi!\" id='caption_span'></span>" ?>
<?php endif ?>

it is modded from the example.php file that comes with the sdk.

Is it actually possible to do this?


There isn't a way to get the user's name without requiring basic information. Tried a few different things myself to get it to show up on my company's app (where show my apps, tos, priv policy, etc) where I really don't need them to allow me any permissions. I just put a generic 'Welcome!' and went with it.


<?php
$json = json_decode(file_get_contents("http://graph.facebook.com/ChrisHughes"));
echo $json->name;

http://sandbox.phpcode.eu/g/35ec0.php

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜