0

I am trying retrieve user name from the code through graph api, the below code was working fine when while I was hosting app on another(godaddy) server but recently I moved the application to phpfog and since then am facing this weird problem.

try {
                $userId = $_POST["user_id"];
                $oauth_token = $_POST["oauth_token"];

                $userName =   json_decode(file_get_contents('https://graph.facebook.com/' . $userId)) -> name;
                $userGender =   json_decode(file_get_contents('http://graph.facebook.com/' . $userId)) -> gender;
                $userPpicture =   json_decode(file_get_contents('http://graph.facebook.com/' . $userId)) -> picture;
            } catch(Exception $e) {
                echo $e -> getMessage();
                echo "<br>";
            }

just to add as this may help that in the very next line i can sucessfully retreive user profile picture through this:

<img class=\"ppicture\" src=\"https://graph.facebook.com/" . $userId . "/picture?type=large\">

Beside this piece of code not working, the photo posting functionality has just also stopped working. kindly help me with this.

thankyou.

Maven
  • 14,587
  • 42
  • 113
  • 174
  • Is the application at the same URL? If not, make sure you add the new domain/subdomain to the authorized list on your facebook app settings ... – keithhatfield Mar 19 '12 at 19:58
  • Url has changed but ive configured App Domain & Site Urls respectively. – Maven Mar 19 '12 at 20:06

2 Answers2

0

The ability to retrieve a user's photo directly (/[user id]/picture) doesn't require a token, so that's not a valid test.

If you've saved your oauth tokens you may need to re-init the user session with the new application address list. To confirm, you should copy the token you're using to FB's debug interface here:

https://developers.facebook.com/tools/debug

Hope that helps.

RSG
  • 7,013
  • 6
  • 36
  • 51
  • how can i re-init the user session? can u kindly brief me a little about it, ive tried reseting aap secret, reauthorizing app from user etc. but none is working? – Maven Mar 19 '12 at 22:31
  • and acc. to debugger my token is `Valid:True` – Maven Mar 19 '12 at 22:33
  • All the work I've done with facebook is through Koala or the javascript SDK. Do you init with the JS SDK as in this example? https://developers.facebook.com/blog/post/534/ – RSG Mar 19 '12 at 23:58
  • no i am not using java script sdk but am doing it from php side, you can have a look at my code [here](http://stackoverflow.com/questions/9761854/browser-redirected-outside-facebook-instead-of-redirecting-it-inside-iframe) ... – Maven Mar 20 '12 at 05:51
0

After consulting phpfog support i came to know that their shared hosting plan doesnot support the function file_get_contents.

Anyone of their dedicated plans will be able to run the commands which are restricted on their shared service.

Maven
  • 14,587
  • 42
  • 113
  • 174
  • Sounds like you better change companies instead of plans. Or try using the curl functions instead of relying on url open wrappers to be enabled. – ThiefMaster Mar 24 '12 at 00:43
  • yeah, but i dont know any better options to switch from `phpfog`, tell me if you know any. :) – Maven Mar 24 '12 at 07:54