English 中文(简体)
您如何使用 FQL 或 Graph API 获取只包含一个有标签用户的照片或照片?
原标题:How do you retrieve a photo or photos containing only one tagged user using either FQL or Graph API?

我试着用FQL和API图来完成这个任务。

我开始尝试FQL的电话:

$fql = "SELECT pic, src_big FROM photo WHERE pid IN (SELECT pid FROM photo_tag WHERE subject = me())";

我从这里得到的结果包括含有给定用户标签的图像(在此情况下:我() ) 。 但是, 这些图像可能包含不止一个贴有标签的用户 。 我希望通过使用 SQL Having 条款和COUNT( http:// stackoverflow.com/ a/ 37105001/ 1406986) 来解决这个问题( http:// stackoverflow. com/ a/ 3710501/1 406986)。 不幸的是,我认为 FQL 并不支持这个功能, 因为当我尝试拨打这个电话时:

$fql = "SELECT pic, src_big FROM photo WHERE pid IN (SELECT pid FROM photo_tag HAVING COUNT(subject) = 1";

我从脸书上留了一个错误。 如果 FQL 实际上支持此功能, 请纠正我 。

为设法利用AIPI图一解决这一问题,提出了以下请求:

$userPics = $facebook->api( /me/photos );

此返回用户照片, 但是, 从这一点上, 我被迫重复每张照片, 寻找只包含一个标签的照片 。 我发现这不切实际, 例如, 如果需要为每个用户的朋友寻找只包含他们朋友而不是其他人的图像 。 要做到这一点, 我就需要单独检索他们每个朋友的照片, 然后再复制所有的照片 。

我还在寻找一个好的解决方案。 请张贴您的想法和解决方案 。

最佳回答

嗯,我已经设法为这个问题创建了一个FQL, 但它一点也不漂亮

SELECT object_id, pid, src_big FROM photo WHERE pid IN
  (SELECT pid FROM photo_tag 
    WHERE pid IN (SELECT pid FROM photo_tag WHERE subject = me()) 
    AND NOT (pid IN 
      (SELECT pid  FROM photo_tag WHERE pid IN 
        (SELECT pid FROM photo_tag WHERE subject = me()) 
      AND subject != me())
    )
  )

<强 > 排除:

第一个很简单, 获得当前用户的相片_ 标签

SELECT pid FROM photo_tag WHERE subject = me()

下一张我加入的同一张桌子, 但是这次我想要我和某人在一起的照片

SELECT pid  FROM photo_tag WHERE pid IN 
  (SELECT pid FROM photo_tag WHERE subject = me()) 
AND subject != me()

我再次加入同一张表格(是3个,和同一张表格合并),但这次我要的是照片_标签,我当时是该照片中唯一贴上标签的用户所在的图片_标签。

SELECT pid FROM photo_tag 
WHERE pid IN (SELECT pid FROM photo_tag WHERE subject = me()) 
   AND NOT (pid IN 
     (SELECT pid  FROM photo_tag WHERE pid IN 
        (SELECT pid FROM photo_tag WHERE subject = me()) 
      AND subject != me())
   )

查询的最后补充是 只是一个连接 从照片的相片表格中获取信息信息 是因为我是唯一一个被贴上标签的人

SELECT object_id, pid, src_big FROM photo WHERE pid IN
  (SELECT pid FROM photo_tag 
    WHERE pid IN (SELECT pid FROM photo_tag WHERE subject = me()) 
    AND NOT (pid IN 
      (SELECT pid  FROM photo_tag WHERE pid IN 
        (SELECT pid FROM photo_tag WHERE subject = me()) 
      AND subject != me())
    )
  )
问题回答

暂无回答




相关问题
Automatically pick tags from context using Python

How can I pick tags from an article or a user s post using Python? Is the following method ok? Build a list of word frequency from the text and sort them. Remove some common words and pick the top ...

Embed font into PDF file by using iText

I defined a tag map, and got a XML data file. I want to convert the XML data file to PDF by using iText. The question is how to embed fonts (e.g. Polish font, Chinese font) into the target PDF when ...

Splitting a string in C#

I was wondering if somebody could help me use string split to get all occurrences of text in between <p> </p> tags in an HTML document?

Tagging Posts via Wordpress XMLRPC

i am trying to publish a new post to a wordpress blog over the XMLRPC API. This works out fine so far, but now i want to add tags to the post. Either at creation time or afterwards. But i can t find ...

linq query for tag system - search for multiple tags

I have two tables, Tags(tagid, postid, tagname) and posts(postid, name, ...) now i want to make a query that returns me all posts that have a generic amount of tags. like: i want all posts that have ...

Is it sometimes bad to use <BR />?

Is it sometimes bad to use <BR/> tags? I ask because some of the first advice my development team gave me was this: Don t use <BR/> ; instead, use styles. But why? Are there negative ...

iphone - Get dynamically created UITextField by tag

I add a UITextField to a table cell dynamically in my app. I d like to implement a "backgroundClick" method to dismiss the keyboard if the user presses outside the textfield (and outside the keyboard) ...

Re-insertion of <script> tags

Insertion of a file s tag, thus executing the file s code. Removal of the file s tag. Insertion of the same file s tag. Firebug does not seem to acknowledge and does not show the reinserted tag ...

热门标签