Some user's album pictures return Unsupported

2019-08-01 02:38发布

问题:

I'm finishing a flash application. You can see the app here:

https://apps.facebook.com/wacky-winter-woolies/

The app sends an FQL query to get the user's albums, generates thumbnails based on cover_object_id. This part works fine. After clicking on an album the app loads photo thumbnails in the same fashion. We've just discovered that although it usually works, for some people and some photos instead of a thumbnail facebook returns the following error:

{"error": {"message": "Unsupported get request.","type": "GraphMethodException"}} picture

The photo thumbnail request URL:

https://graph.facebook.com/(object_id)/picture?type=thumbnail&access_token=(valid_token)

The query used to generate the list of photos in an album:

var fql:String = "SELECT object_id, aid FROM photo WHERE aid = \""+aid+"\"";

The permissions for the app:

'permissions' => 'publish_stream,user_photos,friends_photos'

Essentially some photos return an error. The object_id of the photo is valid as it's pulled right from the FQL result - here is an example of an actual request that returns the error, complete with token

https:// graph.facebook.com/10150102643214148/picture?type=thumbnail&access_token=AAACJlS1owXcBAAh9KIBAYDobeWAvcuHdr96DHYpJJafhHjianz07jWZBYj6klqqZC4cYA2ZCOxTt2fOXCNAH4GBZCPK75nlLdZCZA8xfW2xgZDZD

(note: space is added because as a new user I can't post more than 2 links)

What is causing this? How can this be fixed?


Edit1 :

This is interesting.

Here are the raw object_id's of a set of pictures. One of them is invalid. Guess which?

  • 387476299148
  • 387476299148
  • 10150102643214148
  • 492300644148
  • 492300644148

For some reason for certain pictures in the album FQL returns an unusually long object_id. Those long object_id's are invalid.

As you can see both the valid and invalid IDs end with a similar sequence - 148. Even though I'm handling the result as a string and not removing any characters from the result it's possible facebook wanted to send me 10150_102643214148 instead and slipped.

Currently I'm just throwing out the invalid IDs. I hope this is enough to prevent blank photos and facebook doesn't poison my query results with any more bogus data.


Edit2: The above approach didn't work, for some reason. Some pictures would still result in an error. Fortunately the FQL tables had properties like "src_small" and "src_large" which return the direct link to the photos. Even though graph supposedly allows to retrieve any image using it's API I had to fall back to the src results from the query - I guess that was a patch of sorts for situations like this.

In short Facebook's GRAPH API is broken. I hope it gets fixed soon.

回答1:

I had an identical problem. After fussing with it for 2 hours, I discovered that at times, some albums come back without an ID for the coverphoto (or there isn't a coverphoto).

After putting an if statement in my loop to see if there was in fact an ID before calling the api() function, it took care of this issue.

Below are the 4 relevant functions from one of my classes to demonstrate. (I'll try to bold the specific line below, but I'm new at posting to this site:

public function callAPI($path){
    $params = array('access_token' => $this->access_token);
    $results = $this->_facebookObj->api($path, 'GET', $params );
    return $results;
}

public function listAlbums(){
    $data = $this->_getAlbumsData();
    echo '<ul>';
    try{
    foreach($data as $key => $value){
        if(isset($value['coverPhotoID'])) { $coverImage = $this->getImageInfo($value['coverPhotoID']);}
        echo '<li><img src="' . $coverImage['thumb'] . '"></li>';
        echo '<li>' . $value['albumTitle'] . '</li>';
        if(isset($value['albumDescription'])){echo '<ul><li>Description: ' . $value['albumDescription'] . '</li></ul>';}
    }
    } catch (FacebookApiException $e){
        echo $e->getMessage();
    }
    echo '<ul>';
}



public function getImageInfo($imageID){
    $path = '/' . $imageID;
    $res = $this->callAPI($path);
    $feedArray = array();
        $feedArray['id'] = $res['id'];
        $feedArray['thumb'] = $res['picture'];
        $feedArray['fullImage'] = $res['source'];
        $feedArray['imgHeight'] = $res['height'];
        $feedArray['imgWidth'] = $res['width'];

    return $feedArray;
}

protected function _getAlbumsData()
{
    $feedArray = array();
    $path = '/' . $this->_pageID . '/albums';
$res = $this->callAPI($path);

foreach ($res['data'] as $key => $album) {
        // assign data to $feedArray
        $feedArray[$key]['albumID'] = $album['id'];
        $feedArray[$key]['albumTitle'] = $album['name'];
        $feedArray[$key]['coverPhotoID'] = $album['cover_photo'];
        if(isset($album['description'])){$feedArray[$key]['albumDescription'] = $album['description'];}
        if(isset($album['count'])){$feedArray[$key]['countOfPhotos'] = $album['count'];}

        //create a new Album object with id
        //$albumObj = new Album($album['cover_photo']);
}
    return $feedArray;


}