criso / fbgraph

NodeJs module to access the facebook graph api
http://criso.github.io/fbgraph/
1.09k stars 176 forks source link

Graph API 2.0 #54

Closed chrisjhoughton closed 9 years ago

chrisjhoughton commented 10 years ago

This is more of a discussion opener than a direct issue at this stage, but if you haven't seen - Facebook's just announced a ton of new changes to their API. Most notably for this module, they'll be versioning the API moving forwards.

They've now introduced v2.0, with a number of little tweaks and changes. It would be great to hear what your thoughts are on things. I'd definitely recommend some kind of version global parameter, but to allow for flexibility it should be possible to specify this on the request level as well.

Thoughts?

criso commented 10 years ago

hmm.. looking at the js sdk https://developers.facebook.com/docs/apps/versions adding a version parameter seems ideal. Maybe a version flag within the module so that you won't have to add it every time or you can override it if you pass a version in. Similar to what's being done with the access_token.

So yeah, pretty much what you've just said :+1:

chrisjhoughton commented 10 years ago

Glad we're on the same page! We're pushing our product live tomorrow and migrating everything to v2.0 is one of the top priorities for us, expect a pull request from me over the next few days. I'll also chuck in the access token fixes from https://github.com/criso/fbgraph/issues/46 as well.

Sneppers commented 10 years ago

Any idea on how to get the username now? I did read the FB documentation but it is nowhere to be found.

Thank you.

chrisjhoughton commented 10 years ago

Hi Sneppers, you can use the /me endpoint, which will contain a link parameter. See https://developers.facebook.com/tools/explorer?method=GET&path=me&version=v2.0.

Within this fbgraph module, you can get the same info like this:

graph.get("me", params,  function(err, res) {
  console.log(res); // { picture: "http://profile.ak.fbcdn.net/..." }
});

Note: I wouldn't recommend trying to explicitly get the "username" - not all users have one. Using their link or id parameters will give you much more consistent behaviour.

chrisjhoughton commented 10 years ago

By the way criso, are the tests working for you at the moment? I haven't even merged my changes and I can't get the tests to pass for me.

winzig commented 10 years ago

I think Facebook closed down the link username loophole. I have a username on Facebook, and when I look at my /me results now, the link is now using my userid instead of my username. You could probably follow the redirect for the link, and try to extract the username from that if you really want it.

criso commented 10 years ago

@chrisjhoughton Haven't had a chance to check that out yet.

chrisjhoughton commented 10 years ago

Cool, no rush. We've got it forked with the fix in place here: https://github.com/sauce/fbgraph.

FYI, this forked module is now in production for us.

criso commented 10 years ago

Awesome. The tests have historically been flaky since the connect to FB. Been meaning to change that for a while now. But I need a couple more hours in the day for that ;)

chrisjhoughton commented 10 years ago

I can totally relate there! Would you like me to submit a pull request for the new version of shall I wait on you for the tests?

criso commented 10 years ago

Sure, I think leaving it defaulted to version 1 is the way to go. You a typo on a comment btw: " * - adds the graph API version, defaulting to 2.0"

chrisjhoughton commented 10 years ago

Thanks for your point on the typo - will get that resolved.

Out of interest, what's your thought process behind leaving it set on version 1? Setting on this version will certainly help for now, but as things change over time and Facebook eventually deprecates 1.0, even if 1.0 is set in setGraphVersion, the developer will be forced over to 1.1. In some ways defaulting to the newer version would make life simpler for new developers using fbgraph.

Thoughts? See https://developers.facebook.com/docs/apps/versions

criso commented 10 years ago

Setting to version 1 is purely for the immediate backwards compatibility. Don't want anyone doing a npm update and having to spend time fixing things.

criso commented 10 years ago

@chrisjhoughton are you still planning on a pull request for this?

chrisjhoughton commented 9 years ago

@criso ah yes, I'll make the changes and submit! FYI - in Graph 2.1 (released yesterday), JSON responses are always returned by the API. (No more booleans)

farzd commented 9 years ago

is this by default targeting v1.0 ? me/friends returns 2.0 result, which is just total count. I havent tried prefixing the call with v1.0 so v1.0/me/friends but i assumed this api was targeting 2.0+ by default

chrisjhoughton commented 9 years ago

Facebook automatically targets the oldest version by default, currently v1.1. (Which is not a real version, it's a clone of 1.0)

xpepermint commented 9 years ago

Hey, what's the status? I would like to use the new v2.1 api. Btw @chrisjhoughton, as I can see your fork doesn't change the URL for oauth (here).

chrisjhoughton commented 9 years ago

Sorry for the delay guys, I'm on this now. Will have a pull request in the next hour or so. Thanks @xpepermint for the pointer! I'll re-fork.

shivasurya commented 9 years ago

hello, is this updated for v2.0+ facebook api ! i would like to hear if it is upgraded!

ngethe commented 9 years ago

@shivasurya Yes it version-ed for 2.0 ++