i looking @ facebook sdk first time , want implement using f#. trying access token based on application's appid, appsecret, , clienttoken. looking @ c# example on stackoverflow found here.
how translate c# code?
var fb = new facebookclient(); dynamic result = fb.get("oauth/access_token", new { client_id = "app_id", client_secret = "app_secret", grant_type = "client_credentials" }); fb.accesstoken = result.access_token; f# not allow dynamic typing , not sure how implement that.
thanks in advance.
you can use impromptuinterface.fsharp nuget package enable dynamic lookup via ? operator. enable write result?access_token
the use of anonymous type more difficult translate, because f# doesn't have those. solution depends on how they're used, , while don't know how facebook sdk consumes such values, i'm going assume works same way asp.net web api, uses anonymous types alternative dictionary.
in case, you'll need first create record appropriate properties:
type credentials = { client_id : string client_secret : string grant_type : string } this should enable create new value of type:
{ client_id = "app_id" client_secret = "app_secret" grant_type = "client_credentials" }
Comments
Post a Comment