public async Task <ProfilePictureResult> GetProfilePictureAsync(string userAccessToken, string id = "me", UserProfilePictureOptions profilePictureOptions = null)
        {
            var url = FacebookUrl.GetUrl(FacebookUrl.UserPictureUrl, FacebookApiVersion.Version5, id);

            List <KeyValuePair <string, string> > options;

            if (profilePictureOptions != null)
            {
                options = ModelHelper.GetOptionsAsKeyValue(profilePictureOptions).ToList();
            }
            else
            {
                options = new List <KeyValuePair <string, string> >();
            }

            // By default the picture edge will return a picture instead of a JSON response.
            // If you want the picture edge to return JSON that describes the image set redirect=0 when you make the request.
            options.Add(new KeyValuePair <string, string>("redirect", "0"));

            var request = GraphApiRequestBuilder
                          .BuildRequestTo(url)
                          .WithMethod(HttpMethod.Get)
                          .WithUrlParameters(options)
                          .WithUrlPatameter("fields", string.Join(",", ModelHelper.GetAllModelFields <ProfilePictureResult>()))
                          .WithAccessToken(userAccessToken)
                          .WithAppSecretProof(facebookClient.AppSecret, userAccessToken)
                          .GetHttpRequestMessage();

            return((await facebookClient.SendRequestAsync <DataWrapper <ProfilePictureResult> >(request)).Data);
        }
Exemple #2
0
        private HttpRequestMessage GetAccessTokenRequest(string grantType, string exchangeToken)
        {
            var url = FacebookUrl.GetUrl(FacebookUrl.TokenUrl, FacebookApiVersion.Version5);

            return(GraphApiRequestBuilder
                   .BuildRequestTo(url)
                   .WithMethod(HttpMethod.Get)
                   .WithUrlPatameter("fb_exchange_token", exchangeToken)
                   .WithUrlPatameter("grant_type", grantType)
                   .WithClientIdAndClientSecret((facebookClient.AppId, facebookClient.AppSecret))
                   .GetHttpRequestMessage());
        }
        public async Task <DebugTokenResult> DebugTokenAsync(string inputToken)
        {
            var debugTokenUrl = FacebookUrl.GetUrl(FacebookUrl.DebugTokenUrl, facebookApiVersion);

            return((await facebookClient.SendRequestAsync <DataWrapper <DebugTokenResult> >(
                        GraphApiRequestBuilder
                        .BuildRequestTo(debugTokenUrl)
                        .WithMethod(HttpMethod.Get)
                        .WithUrlPatameter("input_token", inputToken)
                        .WithAccessToken(await facebookClient.GetApplicationAccessTokenAsync())
                        .GetHttpRequestMessage())).Data);
        }
        public async Task <IEnumerable <TestUserResult> > GetTestUsers()
        {
            var url = FacebookUrl.GetUrl(FacebookUrl.TestUserUrl, FacebookApiVersion.Version5, this.facebookClient.AppId);

            var request = GraphApiRequestBuilder
                          .BuildRequestTo(url)
                          .WithMethod(HttpMethod.Get)
                          .WithAccessToken(await facebookClient.GetApplicationAccessTokenAsync())
                          .GetHttpRequestMessage();

            return((await facebookClient.SendRequestAsync <DataWrapper <IEnumerable <TestUserResult> > >(request)).Data);
        }
        public async Task <UserResult> GetUserAsync(string userAccessToken, string id)
        {
            var url = FacebookUrl.GetUrl(FacebookUrl.UserUrl, FacebookApiVersion.Version5, id);

            var request = GraphApiRequestBuilder
                          .BuildRequestTo(url)
                          .WithMethod(HttpMethod.Get)
                          .WithUrlPatameter("fields", string.Join(",", ModelHelper.GetAllModelFields <UserResult>()))
                          .WithAccessToken(userAccessToken)
                          .WithAppSecretProof(facebookClient.AppSecret, userAccessToken)
                          .GetHttpRequestMessage();

            return(await facebookClient.SendRequestAsync <UserResult>(request));
        }