Пример #1
0
        /// <summary>
        /// </summary>
        /// <param name="IdPhoto"></param>
        /// <returns></returns>
        public async Task <string> deleteImageFlicr(string IdPhoto)
        {
            var    baseUriDel  = "https://api.flickr.com/services/rest";
            var    parameters  = new Dictionary <string, string>();
            var    uploadPhoto = new UploadFlickrPhoto(OAuthAccessTokenSecret, Secret);
            var    method      = "POST";
            string signed      = null;

            if (!string.IsNullOrEmpty(OAuthAccessToken))
            {
                parameters = OAuthParameters;
                parameters.Add("oauth_consumer_key", ConsumerKey);
                parameters.Add("oauth_token", OAuthAccessToken);
                parameters.Add("photo_id", IdPhoto);
                parameters.Add("method", "flickr.photos.delete");
                signed = CalculateOAuthSignedUrlPOST(parameters, baseUriDel, OAuthAccessTokenSecret, true);
            }

            var data       = OAuthCalculatePostData(parameters);
            var authHeader = uploadPhoto.OAuthCalculateAuthHeader(parameters);

            try
            {
                var res = await DownloadData(method, signed, data, PostContentType, authHeader);

                var xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(res);
                var node = xmlDoc.SelectSingleNode("/rsp/@stat");
                return(node.InnerText);
            }
            catch (Exception e)
            {
                throw;
            }
        }
Пример #2
0
        public async Task <string> DeleteFav(String idPhoto)
        {
            var baseUriAddFav = "https://api.flickr.com/services/rest";
            var parameters    = new Dictionary <string, string>();
            var uploadPhoto   = new UploadFlickrPhoto(OAuthAccessTokenSecret, Secret);

            if (!string.IsNullOrEmpty(OAuthAccessTokenSecret))
            {
                parameters = OAuthParameters;
                parameters.Add("oauth_consumer_key", ConsumerKey);
                parameters.Add("oauth_token", OAuthAccessToken);
                parameters.Add("photo_id", idPhoto);
                parameters.Add("method", "flickr.favorites.remove");
            }
            var signedUri  = CalculateOAuthSignedUrl(parameters, baseUriAddFav, OAuthAccessTokenSecret, true);
            var method     = "POST";
            var data       = OAuthCalculatePostData(parameters);
            var authHeader = uploadPhoto.OAuthCalculateAuthHeader(parameters);

            try
            {
                var res = await DownloadData(method, signedUri, data, PostContentType, authHeader);

                var xmlDoc = new XmlDocument();
                xmlDoc.LoadXml(res);
                var node = xmlDoc.SelectSingleNode("/rsp/@stat");
                return(node.InnerText);
            }
            catch (Exception e)
            {
                MessageDialog msg_failure = new MessageDialog(e.Message + "\n Problème suppresion photo favorite");
                return(null);
            }
        }