如何获取使用facebook graph api上传的照片链接

时间:2017-02-01 09:30:09

标签: php facebook facebook-graph-api

我已使用以下代码

成功将照片上传到用户的相册
      $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;
      }

现在我想检索此图片的链接。为此我检索了这张照片的ID

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

使用此ID我尝试获取此图像的链接,如下所示。

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

但我无法收到链接,因为$ fb-> get('/'。$ photo_id);不会返回此链接。

请告诉我如何使用其ID

获取上传图片的链接

0 个答案:

没有答案