node.jsfacebook-graph-apifacebook-opengraphopen-graph-beta

How to provide information in the html link for Facebook open graph api call of "property name" when posting trying to post an action


I am trying to create an html object dynamically with the necessary header information depending on the query string in the link I provide to Facebook. I am hoping that Facebook open graph will call this html link as I provided. However it seems that query string info are not getting passed to my server. Do anyone know how to make this work or what is the more appropriate way to do this. BTW, I am writing my code in Node.js.

To get more info about Facebook open graph api, look here, https://developers.facebook.com/docs/beta/opengraph/actions/.

For example, the link I am trying to pass to Facebook is, "http://xxx-url.com/getFacebookObject?objectId=&description=first dynamic post", so I sent a request with the link as, "https://graph.facebook.com/me/app-name:action-name?object=http://xxx-url.com/getFacebookObject?objectId=&description=first dynamic post". However, when I check the log on the server, I don't see anything in the query string.


Solution

  • Instead of using the query string, you can embed the data in the URL:

    http://some-domain.com/getFacebookObject/id/description
    

    Then, depending on what node.js packages you're using, extract the data from the request:

    // expess.js style
    app.get("/getFacebookObject/:id/:description", function(req, res) {
      var id = req.params.id,
        desc = req.params.description;
      // your code...
    });
    

    (See http://expressjs.com/guide.html.)