Question

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.

Was it helpful?

Solution 2

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.

OTHER TIPS

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.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top