facebook/graph/fdl library for D
Adam D. Ruppe
destructionator at gmail.com
Thu Jun 14 06:33:32 PDT 2012
On Thu, Jun 14, 2012 at 12:04:10PM +0200, Andrea Fontana wrote:
> Does it exist?
I have a kind of one:
http://arsdnet.net/dcode/oauth.d
(it isn't on my github because I still haven't cleaned it up much)
The main function you want is fbGraph() which does a request via
curl
and returns it as a Variant[string].
Variant[string] fbGraph(string[] info, string id, bool useCache =
false, long maxCacheHours = 2) {
The info takes [null, access_token] (the first argument is
obsolete, but so much
of my code passes an array that I didn't want to change it).
The second argument is the Facebook ID or the connection you
want. For example
"adam.d.ruppe"
or "adam.d.ruppe/friends".
Then the cache function will save to a local file in /tmp (this
thing assumes linux)
and pull from it for up to maxCacheHours instead of asking the
network.
The getBasicDataFromVariant function is a convenience once to
pull just very basic
info out of some requests, for example, /friends, which returns {
"data" : [] } format.
I don't do a lot of posting, but postToFacebookWall does a wall
message. It needs
your token to have publish_stream.
Getting permission is not in that file. I have functions for it,
but they are in
one of my proprietary files so I have to make sure it is all
sanitized before
I pull it out (which isn't easy since they save it to the app's
database too).
The basic ideas though is to just redirect them here:
return (stripWhitespace(
"http://www.facebook.com/dialog/oauth/?
scope="~scopeWanted~"&
client_id="~appId~"&
redirect_uri="~std.uri.encodeComponent(action)
~"&
response_type=code"
));
Learn more here:
http://developers.facebook.com/docs/reference/dialogs/oauth/
More information about the Digitalmars-d-learn
mailing list