place_id链接到foursquare?

时间:2014-04-22 23:22:43

标签: facebook facebook-graph-api facebook-fql

使用fql我得到了一些照片。 Photo表包含字段place_id,其中我的大多数照片都是页面表上的page_id - 没问题。但用Instagram拍摄的照片有place_id但不对应任何页面,当我用facebook查看照片时:该地点链接到foursquare页面。

我的疑问是:如何通过place_id获得与foursquare的正确链接?因为我需要知道拍照的位置。

示例:

place_id是' 10150673541763630'
Facebook中的照片place link是' https://pt.foursquare.com/v/pra%C3%A7a-da-alegria/4caf06ba39458cfa4fcbf69f'

谢谢。

1 个答案:

答案 0 :(得分:0)

不确定您要在此处实现的目标...如果您使用Graph API查询object_id 10150673541763630,则会收到以下查询:

https://graph.facebook.com/10150673541763630?metadata=1

我添加了metadata=1参数,以便您可以看到这不是一个位置对象,而是一个类型为opengraphobject:playfoursquare:venue的Opengraph对象:

{
  "id": "10150673541763630", 
  "application": {
    "id": "86734274142", 
    "name": "Foursquare", 
    "url": "https://www.facebook.com/apps/application.php?id=86734274142"
  }, 
  "created_time": "2012-03-15T09:54:03+0000", 
  "data": {
    "location": {
      "latitude": 38.717880681017, 
      "longitude": -9.1449693651909
    }, 
    "number_of_tips": 4, 
    "appears_on_lists": [
      {
        "id": "140732802766102", 
        "title": "lisboa", 
        "type": "playfoursquare:list", 
        "url": "https://foursquare.com/user/13257476/list/50e1baefe4b08361cf80d168"
      }, 
      {
        "id": "1375724855996686", 
        "title": "lisbon", 
        "type": "playfoursquare:list", 
        "url": "https://foursquare.com/user/29376791/list/51bb16d5498e67eeccae7fe6"
      }, 
      {
        "id": "516155125119081", 
        "title": "Lisboa cidade mais linda do mundo", 
        "type": "playfoursquare:list", 
        "url": "https://foursquare.com/user/48582854/list/519e166a498eda6c7172e41f"
      }, 
      {
        "id": "513522255419487", 
        "title": "Viagens", 
        "type": "playfoursquare:list", 
        "url": "https://foursquare.com/user/15581998/list/51192e94e4b051a095440d50"
      }
    ]
  }, 
  "image": [
    {
      "height": 600, 
      "url": "https://irs0.4sqi.net/img/general/600x600/49647321_ncDPc4_3OJUkYvj6CbwNHSyFIEJ79gqUuod5tGlXuL0.jpg", 
      "width": 600
    }, 
    {
      "url": "https://irs0.4sqi.net/img/general/600x600/XYS8qBTzuJfSX0k-8cAqU7XXQMZ4eigkm3gG7izySHI.jpg"
    }, 
    {
      "url": "https://irs0.4sqi.net/img/general/600x600/rWkkCyKRDWMA7IiGjHmw07ESIOapLFUFJq5D60beSHw.jpg"
    }, 
    {
      "url": "https://irs1.4sqi.net/img/general/600x600/nT0Yk6Houl-9biiwOqzTeSK56v1sXHTlnnYMyK1Iin0.jpg"
    }
  ], 
  "is_scraped": true, 
  "site_name": "Foursquare", 
  "title": "Praça da Alegria", 
  "type": "playfoursquare:venue", 
  "updated_time": "2014-04-22T23:10:39+0000", 
  "url": "https://foursquare.com/v/pra%C3%A7a-da-alegria/4caf06ba39458cfa4fcbf69f", 
  "metadata": {
    "fields": [
      {
        "name": "id", 
        "description": "The Open Graph object ID", 
        "type": "numeric string"
      }, 
      {
        "name": "admins", 
        "description": "A list of admins", 
        "type": "list<opengraphobjectprofile>"
      }, 
      {
        "name": "application", 
        "description": "The application that created this object", 
        "type": "opengraphobjectprofile"
      }, 
      {
        "name": "audio", 
        "description": "A list of audio URLs", 
        "type": "list<opengraphobjectaudio>"
      }, 
      {
        "name": "created_time", 
        "description": "The time the object was created", 
        "type": "datetime"
      }, 
      {
        "name": "data", 
        "description": "Custom properties of the object", 
        "type": "opengraphstruct:playfoursquare:venue"
      }, 
      {
        "name": "description", 
        "description": "A short description of the object", 
        "type": "string"
      }, 
      {
        "name": "determiner", 
        "description": "The word that appears before the object's title", 
        "type": "string"
      }, 
      {
        "name": "image", 
        "description": "A list of image URLs", 
        "type": "list<opengraphobjectimagevideo>"
      }, 
      {
        "name": "is_scraped", 
        "description": "Whether the object has been scraped", 
        "type": "bool"
      }, 
      {
        "name": "locale", 
        "description": "The locale the object is in", 
        "type": "opengraphobjectlocale"
      }, 
      {
        "name": "post_action_id", 
        "description": "The action ID that created this object", 
        "type": "id"
      }, 
      {
        "name": "profile_id", 
        "description": "The Facebook ID of a user that can be followed", 
        "type": "opengraphobjectprofile"
      }, 
      {
        "name": "restrictions", 
        "description": "Any restrictions that are placed on this object", 
        "type": "opengraphobjectrestrictions"
      }, 
      {
        "name": "see_also", 
        "description": "An array of URLs of related resources", 
        "type": "list<string>"
      }, 
      {
        "name": "site_name", 
        "description": "The name of the web site upon which the object resides", 
        "type": "string"
      }, 
      {
        "name": "title", 
        "description": "The title of the object as it should appear in the graph", 
        "type": "string"
      }, 
      {
        "name": "type", 
        "description": "The type of the object", 
        "type": "string"
      }, 
      {
        "name": "updated_time", 
        "description": "The last time the object was updated", 
        "type": "datetime"
      }, 
      {
        "name": "url", 
        "description": "The canonical URL of the object, used as its ID in the graph", 
        "type": "string"
      }, 
      {
        "name": "video", 
        "description": "A list of video URLs", 
        "type": "list<opengraphobjectimagevideo>"
      }
    ], 
    "type": "opengraphobject:playfoursquare:venue", 
    "connections": {
      "comments": "https://graph.facebook.com/10150673541763630/comments", 
      "likes": "https://graph.facebook.com/10150673541763630/likes", 
      "picture": "https://graph.facebook.com/10150673541763630/picture"
    }
  }
}

您可以使用以下查询查找Instagram为实际用户发布的所有照片:

select object_id, place_id from photo where aid in (select aid from album where name="Instagram Photos" and owner=me())

然后,您可以遍历列表并通过标准Graph API请求每张照片的详细信息,如上所示。然后,您在结果对象中找到data.location下面的位置。

或者,您可以使用Batch API一次请求多个对象(https://developers.facebook.com/docs/graph-api/making-multiple-requests/),或者用逗号连接place_ids并发出如下请求:

https://graph.facebook.com/?ids={og_place1_id},{og_place2_id}&fields=id,data.location