Search code examples
facebookfacebook-fqlrestfb

Get object_id of the last message


Using FQL, is there a way to get the object_id of the last message posted by a user (the user_id being known)?          


Solution

  • SELECT post_id, created_time, message, 
           substr(post_id, strpos(post_id, "_") + 1, strlen(post_id))
      FROM stream 
     WHERE source_id = me() AND actor_id=me() 
     LIMIT 1
    

    The stream table doesn't offer an object_id field, which explains why we have to make a little string subtract (substr) to get it. Indeed, a POSTID is made as such: USERID_OBJECTID.


    Result:

    {
      "data": [
        {
          "post_id": "1022361234_10201571234567890", 
          "created_time": 1383606736, 
          "message": "My message", 
          "anon": "10201571234567890"
        }
      ]
    }
    

    Used doc: