javascript - facebook sharing in Angular Application - Stack Overflow

I am working on an Angular Web Application,I am trying to share my content on facebookWhen I am trying

  • I am working on an Angular Web Application,
  • I am trying to share my content on facebook
  • When I am trying to share facebook popup opens and I am getting message href should represent a valid URL
  • I want to share content like

'Use Referral code xyzUvK to join the newest fantasy sports platform . Earn extra points along with lots of exciting prizes. Don’t delay, join the match today! url',

code

html

 <a href="#" (click)="fb($event)"><img src="assets/imgs/fb.svg"/></a>

ts

fb(e) {
    let url = 'www.google';
    e.preventDefault();
    var facebookWindow = window.open(
      '.php?u='+ 'Use Referral code ->' + this.userData.referCode + '   to join the newest fantasy sports platform' +  url + '. Earn extra points along with lots of exciting prizes. Don’t delay, join the match today! url',
      'facebook-popup',
      'height=350,width=600'
    );
    if (facebookWindow.focus) {
      facebookWindow.focus();
    }
    return false;
  }
  • I am working on an Angular Web Application,
  • I am trying to share my content on facebook
  • When I am trying to share facebook popup opens and I am getting message href should represent a valid URL
  • I want to share content like

'Use Referral code xyzUvK to join the newest fantasy sports platform http://example. . Earn extra points along with lots of exciting prizes. Don’t delay, join the match today! url',

code

html

 <a href="#" (click)="fb($event)"><img src="assets/imgs/fb.svg"/></a>

ts

fb(e) {
    let url = 'www.google.';
    e.preventDefault();
    var facebookWindow = window.open(
      'https://www.facebook./sharer/sharer.php?u='+ 'Use Referral code ->' + this.userData.referCode + '   to join the newest fantasy sports platform' +  url + '. Earn extra points along with lots of exciting prizes. Don’t delay, join the match today! url',
      'facebook-popup',
      'height=350,width=600'
    );
    if (facebookWindow.focus) {
      facebookWindow.focus();
    }
    return false;
  }
Share Improve this question edited Mar 19, 2019 at 7:56 Anurag Ranjan asked Mar 18, 2019 at 5:39 Anurag RanjanAnurag Ranjan 1691 gold badge2 silver badges9 bronze badges 3
  • I think FB won't allow us to share content like twitter does – Pardeep Jain Commented Mar 18, 2019 at 5:41
  • @PardeepJain then what is the sollution for this – Anurag Ranjan Commented Mar 19, 2019 at 9:49
  • @AnuragRanjan did you found any solution for this.? i think my issue is beacause of iam testing in local machine? – Mohammed Commented Dec 13, 2021 at 11:55
Add a ment  | 

2 Answers 2

Reset to default 1

Please add meta tags in your index.html file

Markup Example

For example, here's how to mark up an article, news story or blog post with og:type="article" and several additional properties:

<meta property="og:url"                content="http://www.nytimes./2015/02/19/arts/international/when-great-minds-dont-think-alike.html" />
<meta property="og:type"               content="article" />
<meta property="og:title"              content="When Great Minds Don’t Think Alike" />
<meta property="og:description"        content="How much does culture influence creative thinking?" />
<meta property="og:image"              content="http://static01.nyt./images/2015/02/19/arts/international/19iht-btnumbers19A/19iht-btnumbers19A-facebookJumbo-v2.jpg" />

Facebook only allows you to share URLs, not prefilled text like twitter. So your u parameter has to be a URL.

https://developers.facebook./policy#control

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745414078a4626665.html

相关推荐

  • javascript - facebook sharing in Angular Application - Stack Overflow

    I am working on an Angular Web Application,I am trying to share my content on facebookWhen I am trying

    3小时前
    40

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信