Jennifer Mawhinney
Jennifer Mawhinney

Reputation: 71

How to query FQL Stream by Attachment.Media.Type?

When I query the stream table, how do I use attachment.media.type in a WHERE clause? The type field that is the sibling to attachment is always null and I've read that it was deprecated so that is why I want to access the one inside of attachment.

The structure of the attachment field array is:

      "attachment": {
        "name": "My Title",
        "media": [
          {
            "href": "http://www.stackoverflow.com",
            "alt": "",
            "type": "link",
            "src": "http://somephotourlhere"
          }
        ]

I'd want to do something like this (which does not work):

WHERE attachment.media["type"] = "link"

Upvotes: 1

Views: 1475

Answers (1)

cpilko
cpilko

Reputation: 11852

The attachment.media field is an array. To the best of my knowledge, FQL can't return values from inside an array.

If you want to find links you can use AND type = 80 in your FQL.

However, Posted photos also have a type = 80. To filter these out, add

AND type = 80 AND attachment.fb_object_type != 'photo' 

or

AND type = 80 AND strlen(attachment.fb_object_type) < 1

to protect against future objects that may also return type = 80. For links, attachment.fb_object_type is undefined.

Upvotes: 4

Related Questions