首页 > 解决方案 > 用于在 Twitter 上发布视频的 Angular 8 社交分享按钮

问题描述

我是 Angular 8 的新手。如何在按钮点击时在 Twitter 上发布我的 Angular 视频?使用这些代码,我可以在 twitter 上分享图片,但不能分享视频。所以我想如果有人知道如何分享视频。

html

<div class="modal-footer pt-0 border-top-0">
        <div class="button-box">
            <button type="button" class="btn btn-primary" (click)="onTwitter(TwitterComment.value)"><span>Post</span></button>
        </div>
    </div>

TS代码:

onTwitter(TwitterComment) {
        var CloudUrl = this.ImageBigThumbPath;
        this.service.formData = new PartnerWebPhotos;
        this.service.formData.CloudImageUrl = this.ImageBigThumbPath;
        this.service.formData.TwitterComment = TwitterComment;
        this.service.Twitter(this.service.formData).then(
          (res) => {
            console.log(this.service.formData.TwitterAuthToken);
            window.open(this.service.formData.CloudImageUrl, 'popup_window', 'left=50,top=50,width=400,height=400,titlebar=0,toolbar=0,resizable=false');
            this.service.twitterPost();
            this.modalRef.hide();
          },
          (err: HttpErrorResponse) => {
            console.log(err);
    
          }) }

服务电话

    twitterPost()
         {           
            return this.http.get(this.rootURL+'/ClaimPhotos/twitterPost')
         }
Twitter(formData:PartnerWebPhotos )
     {           
        return this.http.post(this.rootURL+'/ClaimPhotos/twitter',formData).toPromise()
        .then(res => this.formData = res as PartnerWebPhotos);;
     }

WebApi 调用

[HttpPost("twitter")]
        public async Task<ActionResult<PartnerWebPhotos>> TwitterPost(PartnerWebPhotos partnerWebPhotos)
        {
            TempData["close"] = null;
            string AuthTokens = string.Empty;
            TempData["msg"] = null;
            if (partnerWebPhotos.CloudImageUrl != null)
            {
                partnerWebPhotos.CloudImageUrl = partnerWebPhotos.CloudImageUrl.Replace("https://res.cloudinary.com/www-commdel-net/image/upload/", "https://res.cloudinary.com/www-commdel-net/image/upload/" + "w_500,h_500,c_fit/");
                TwitterPath = partnerWebPhotos.CloudImageUrl;
                TwitterComment = partnerWebPhotos.TwitterComment;
                //Session["Redirect"] = 2;
                string response = await utility.RequestToken();
                if (response != string.Empty)
                {
                    string[] responseArray = response.Split('&');
                    string RequestToken = responseArray[0].Split('=')[1];
                    TokenSecret = responseArray[1].Split('=')[1];
                    AuthToken = responseArray[0].Split('=')[1];
                    //EditPhotoModel.comments = "";
                    AuthTokens = AuthToken;
                    partnerWebPhotos.CloudImageUrl = "https://api.twitter.com/oauth/authorize?oauth_token=" + AuthToken;
                }
            }
            return partnerWebPhotos;// "OpenTwitterLogin( '" + AuthTokens + "')";
        }

标签: angular

解决方案


推荐阅读