某些用户的相册图片返回不受支持的获取请求,其他工作正常 [英] Some user's album pictures return Unsupported get request, other work fine

查看:187
本文介绍了某些用户的相册图片返回不受支持的获取请求,其他工作正常的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在完成一个Flash应用程序。你可以在这里看到应用程序:



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



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

lockquote

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

照片缩略图请求URL:


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


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


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

应用的权限:


'permissions'=>'publish_stream,user_photos,friends_photos




基本上一些照片返回一个错误。这张照片的object_id是有效的,因为它是从FQL结果中拉出来的 - 这里是一个实际请求的例子,返回错误,用令牌完成

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



(注:空间被添加,因为我可以一个新的用户不要超过2个链接)



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






Edit1:

很有意思。

以下是一组图片的原始object_id。其中之一是无效的。猜猜看哪个?

$ ul
387476299148
387476299148

  • 10150102643214148

  • 492300644148

  • 492300644148



  • 对于相册中的某些图片,FQL会返回一个异常长的object_id。那些长的object_id是无效的。正如你可以看到,有效和无效的ID都以类似的顺序结束 - 即使我将结果作为一个字符串处理,而不是从字符串中删除任何字符结果是可能的Facebook想送我10150_102643214148而滑倒。

    目前我只是扔出无效的ID。我希望这足以防止空白的照片和Facebook不会更多的虚假数据中毒我的查询结果。




    Edit2:由于某种原因,上述方法无效。有些图片仍然会导致错误。幸运的是,FQL表具有诸如src_small和src_large之类的属性,这些属性返回到照片的直接链接。即使图似乎允许使用它的API检索任何图像,我不得不退回到查询的src结果 - 我想这是一个类似于这种情况的补丁。

    简而言之,Facebook的GRAPH API被打破了。我希望很快得到解决。

    解决方案

    我有一个相同的问题。经过两个小时的忙碌之后,我发现有时候一些专辑没有coverphoto的ID(或者没有封面照片)而回来。

    之后在我的循环中放入一个if语句来查看在调用api()函数之前是否实际上有一个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 [ 'album description'])){echo'< ul>< li> Description:'。$ value ['albumDescription']。'< / li>< / ul>';}
    }
    } catch(FacebookApiException $ e){
    echo $ e-> getMessage();
    }
    echo'< ul>';



    $ b public function getImageInfo($ imageID){
    $ path ='/'。 $图像标识;
    $ 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'];

    返回$ feedArray;


    保护函数_getAlbumsData()
    {
    $ feedArray = array();
    $ path ='/'。 $ this-> _pageID。 /相册;
    $ res = $ this-> callAPI($ path);
    $ b foreach($ res ['data'] as $ key => $ album){
    //将数据分配给$ 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'];}

    //创建一个新的相册对象,其ID为
    / / $ albumObj =新专辑($ album ['cover_photo']);
    }
    return $ feedArray;


    }


    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.

    解决方案

    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;
    
    
    }
    

    这篇关于某些用户的相册图片返回不受支持的获取请求,其他工作正常的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

    查看全文
    登录 关闭
    扫码关注1秒登录
    发送“验证码”获取 | 15天全站免登陆