0

I have successfully uploaded a photo to user's album using following code

      $data = [
        'message' => 'My awesome photo upload example.',
        'source' => $fb->fileToUpload($merged_picture_path),
      ];

      try {
        // Returns a `Facebook\FacebookResponse` object
        $response = $fb->post('/me/photos', $data, $accessToken);
        //print_r($response);
       // echo "Posted with id: " . $response->getProperty('id');
      } catch(Facebook\Exceptions\FacebookResponseException $e) {
        echo 'Graph returned an error: ' . $e->getMessage();
        exit;
      } catch(Facebook\Exceptions\FacebookSDKException $e) {
        echo 'Facebook SDK returned an error: ' . $e->getMessage();
        exit;
      }

Now I want to retrieve the link to this image.For that I retrieved the id of this photo

      $graphNode = $response->getGraphNode();
      $photo_id=$graphNode->getProperty('id');

Using this id I try to get the link to this image as follow.

      try {
        $pictue = $fb->get('/'.$photo_id);
        print_r($pictue);
        header("Location: ".$pictue->getProperty('link')."&makeprofile=1");
      }

But I am unable to receive the link since $fb->get('/'.$photo_id); does not return this link.

Please tell me how to get this link to the uploaded image using its id

Dijish U.K
  • 159
  • 1
  • 22
  • You don’t get the `link` field, because you are not _asking_ for it. – CBroe Feb 01 '17 at 09:34
  • how to ask for the link – Dijish U.K Feb 01 '17 at 09:44
  • See the answer in the duplicate. (Yes, that is for the JS SDK. How to pass the same parameter when making requests using the PHP SDK, can be found in the documentation and examples for the latter.) – CBroe Feb 01 '17 at 10:07

0 Answers0