Пример #1
0
        public PhotoUpload UploadPhoto(string token, byte[] image, string name, string contentType, string caption)
        {
            var uploadPhotoUrl = new Uri(string.Format(CultureInfo.InvariantCulture, "{0}/me/photos", UrlResources.GraphApiUrl));

            var parameters = new ContentBuilder();
            parameters.AddParameter("access_token", token);
            parameters.AddParameter("message", caption);

            using (HttpClient client = new HttpClient())
            {
                using (var body = parameters.BuildMultiPartContent(image, name, contentType))
                {
                    using (var response = client.Post(uploadPhotoUrl, body).EnsureStatusIsSuccessful())
                    {
                        return response.Content.ReadAsJsonDataContract<PhotoUpload>();
                    }
                }
            }
        }
Пример #2
0
        public void SetStatus(string token, string status)
        {
            var userStatusSetUrl = new Uri(string.Format(CultureInfo.InvariantCulture, "{0}/me/feed", UrlResources.GraphApiUrl));

            var parameters = new ContentBuilder();
            parameters.AddParameter("access_token", token);
            parameters.AddParameter("message", status);

            using (HttpClient client = new HttpClient())
            {
                using (var response = client.Post(userStatusSetUrl, parameters.BuildFormContent()).EnsureStatusIsSuccessful())
                {
                }
            }
        }