コード例 #1
0
        public async Task <string> AddVideoObject(string accessToken, string videoUrl, string imageUrl, string title)
        {
            var appId = configuration["Authentication:Facebook:AppId"];

            var opengraphobject =
                $"{{\"og:url\":\"{videoUrl}\",\"og:title\":\"{title}\",\"og:image\":\"{imageUrl}\"}}";
            //   $"{{\"fb:app_id\":\"{appId}\",\"og:type\":\"video.other\",\"og:url\":\"{videoUrl}\",\"og:title\":\"{title}\",\"og:image\":\"{imageUrl}\"}}";

            var response = await facebookClient.PostAsync <dynamic>(accessToken, $"app/objects/video.other", new { @object = opengraphobject });

            return(response.id);
        }
コード例 #2
0
        public async Task <object> StartLiveStreamAsync(string accessToken, string userId, object dto = null)
        {
            if (dto == null)
            {
                dto = new { Status = "LIVE_NOW", Title = "Live Today", Description = "This is the live video for today." };
            }

            var result = await _facebookClient.PostAsync(accessToken, $"{userId}/live_videos", dto);

            result.EnsureSuccessStatusCode();

            return(await result.Content.ReadAsStringAsync());
        }
コード例 #3
0
 public async Task PostOnWallAsync(string accessToken, string pageid = "me", string message = "", string link = "", List <attached_media> attached_media = null, string PostedVideo = "")
 {
     if (PostedVideo != "")
     {
         var postVideo = UploadVideoOnWallAsync(accessToken, pageid, PostedVideo, message);
         try {
             Task.WaitAll(postVideo);
         } catch {
         }
         //Task[] array = new Task[] { postVideo };
     }
     else
     {
         await _facebookClient.PostAsync(accessToken, pageid = "/feed", new { message, link, attached_media });
     }
 }
コード例 #4
0
        public async Task <string> PostImageToInstagram(Page page, string imageUrl, string caption)
        {
            var igAccount = page.InstagramAccounts.FirstOrDefault();

            if (igAccount == null)
            {
                throw new Exception("Instagram account is missing. ");
            }

            var objectToPost = new object();
            var argsString   = $"image_url={imageUrl}&caption={caption}";

            var response = await _facebookClient.PostAsync(page.AccessToken, $"{igAccount.Id}/media", objectToPost, argsString);

            if (response == null || !response.IsSuccessStatusCode)
            {
                throw new Exception("Unable to post an image. ");
            }

            // TODO: FB Api doesn't work
            throw new NotImplementedException();
        }
コード例 #5
0
 public async Task PostOnWallAsync(string accessToken, string message)
 => await _facebookClient.PostAsync(accessToken, "me/feed", new { message });
コード例 #6
0
 public async Task PostAccountAsync(Account account)
 => await _facebookClient.PostAsync(account);