部分用户相册图片返回不支持的get请求,其他工作正常

发布于 2024-12-18 18:41:10 字数 1924 浏览 1 评论 0原文

我正在完成一个 Flash 应用程序。您可以在此处查看该应用程序:

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

应用发送FQL查询来获取用户的相册,根据cover_object_id生成缩略图。这部分工作正常。单击相册后,应用程序会以相同的方式加载照片缩略图。我们刚刚发现,虽然它通常有效,但对于某些人和某些照片,Facebook 返回以下错误,而不是缩略图:

{"error": {"message": "不支持的获取请求。","type": “GraphMethodException”}}图片

照片缩略图请求URL:

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

用于生成相册中照片列表的查询:

var fql:String = "从照片中选择 object_id, 援助,其中援助 = \""+aid+"\"";

应用程序的权限:

'权限' => 'publish_stream,用户照片,朋友照片'

本质上有些照片会返回错误。照片的 object_id 是有效的,因为它是从 FQL 结果中直接提取的 - 这是返回错误的实际请求的示例,并带有令牌

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

(注意:添加空格是因为作为新用户我不能发布超过 2 个链接)

是什么原因造成的?如何解决这个问题?


编辑1:

这很有趣。

这是一组图片的原始 object_id。其中一项无效。猜猜是哪一个?

  • 387476299148
  • 387476299148
  • 10150102643214148
  • 492300644148
  • 492300644148

由于某些原因,相册中的某些图片 FQL 返回异常长的 object_id。那些长 object_id 无效。

正如您所看到的,有效 ID 和无效 ID 都以类似的序列结尾 - 148。即使我将结果作为字符串处理,并且没有从结果中删除任何字符,但 facebook 可能想向我发送 10150_102643214148,但却错过了。

目前我只是扔掉无效的 ID。我希望这足以防止空白照片,并且 Facebook 不会用更多虚假数据污染我的查询结果。


Edit2:由于某种原因,上述方法不起作用。有些图片仍然会导致错误。幸运的是,FQL 表具有“src_small”和“src_large”等属性,可返回照片的直接链接。尽管 graph 据称允许使用它的 API 检索任何图像,但我不得不回退到查询的 src 结果 - 我猜这是针对此类情况的补丁。

简而言之,Facebook 的 GRAPH API 已损坏。我希望它能尽快修复。

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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

娇柔作态 2024-12-25 18:41:10

我有一个同样的问题。经过两个小时的折腾,我发现有时有些专辑返回时没有封面照片的 ID(或者没有封面照片)。

在调用 api() 函数之前,在我的循环中放入 if 语句以查看是否确实存在 ID 后,它就解决了这个问题。

下面是我的一门课程中要演示的 4 个相关函数。 (我会尝试将下面的特定行加粗,但我是在这个网站上发帖的新手:

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;


}

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;


}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文