1

I want my tweeter share button to work like the tweets actually work showing image, title and description. I have given Twitter Cards but it's not working and I don't understand why. My G+ is working perfectly and I am having some issues with Twitter and Facebook share.

My anchor tag for Twitter share is below

<a class="fa fa-twitter" href="https://twitter.com/intent/tweet?status=<?php echo base_url(); ?>index.php/Testimonials/fb_share/<?php echo $row->client_id; ?>" target="_blank"><i class="icomoon-icon-twitter"></i><span class="share-title"></span></a>

I also tried with url in place of status but still no luck

 <a class="fa fa-twitter" href="https://twitter.com/intent/tweet?url=<?php echo base_url(); ?>index.php/Testimonials/fb_share/<?php echo $row->client_id; ?>" target="_blank"><i class="icomoon-icon-twitter"></i><span class="share-title"></span></a>

My Twitter cards are below

  <!-- Twitter Card data -->
<meta name="twitter:card" content="summary">
<meta name="twitter:site" content="http://quanutrition.com/Dotcom/new/">
<meta name="twitter:title" content="<?php echo $res['name'];?>">
<meta name="twitter:description" content="<?php echo $res['content1'];?>">
<meta name="twitter:creator" content="@author_handle">
<meta name="twitter:image" content="http://quanutrition.com/Dotcom/new//admin/assets/uploads/clients_image/<?php echo $res['image'];?>">
<!-- Twitter summary card with large image must be at least 280x150px -->
<meta name="twitter:image:src" content="http://quanutrition.com/Dotcom/new//admin/assets/uploads/clients_image/<?php echo $res['image'];?>">

The $res variable looks something like this for a particular client_id

Array ( [client_id] => 1 [name] => Shikhar Dhawan [image] => shikhar-dhawan-759.jpg [video] => [content1] => "Nutrition plays a key role in my recovery and performance. Using Sports Gene testing and advance nutritional blood biochemistry helps me. Eating with a plan gets more scientific and result oriented this way."

Now I am not understanding why the Twitter cards are not working. I did G+ in the exact same manner and it worked perfectly. Can anybody suggest how to solve this?

2 Answers2

2

First of all, you must ensure that your meta tags are available in the final static output for the URL you are sharing.

In the case of one example testimonial page http://quanutrition.com/Dotcom/new/index.php/Testimonials/fb_share/4 I see this:

<meta name="twitter:card" content="summary_large_image"> <meta name="twitter:site" content="http://quanutrition.com/Dotcom/new/"> <meta name="twitter:title" content="S. Danush"> <meta name="twitter:description" content=""Qua Nutrition has helped me grow physically, sports-wise in a healthy manner and explore my strength through right nutrition. I thank my vibrant coach Mr.Veerabadran, who showed me the way to Qua Nutrition and thank my Nutritionist Suhasini for her dedicated support and guidance in helping me achieve my dream. The systematic approach of dietitians and minuscule study of body elements are the strengths of QUA. Wish that every athlete gets an opportunity to visit Qua Nutrition and get the best out of them!" "> <meta name="twitter:creator" content="@author_handle"> <!-- Twitter summary card with large image must be at least 280x150px --> <meta name="twitter:image:src" content="http://quanutrition.com/Dotcom/new//admin/assets/uploads/clients_image/DanushS.jpg">

The twitter:description tag is broken because it has a double quotation mark on either side of the value for content.

The twitter:creator tag is generic.

The twitter:image:src tag name should be twitter:image. This is in the cards documentation.

Testing your links in the Twitter Card Validator results in: ERROR: Failed to fetch page due to: DnsResolutionRequestTimeout

This is likely because either your host is blocking Twitter's IP addresses, or there is a slow DNS resolution (5+ seconds) for your domain.

There's troubleshooting advice on Twitter's developer forums and documentation site.

Andy Piper
  • 11,422
  • 2
  • 26
  • 49
  • Please suggest me a way to solve the DNS issue. Shuld I whitelist twitter's ip address? If yes, then how can I get twitter's ip address? – Sayantan Mitra Sep 12 '17 at 10:38
  • This is listed in the Troubleshooting documentation. The IP ranges are clearly described here https://dev.twitter.com/cards/troubleshooting (search for "IP ranges"). If there's any other DNS issue that is beyond the scope of Twitter's documentation. – Andy Piper Sep 12 '17 at 10:39
1

Please replace "status" with "url", in your anchor tag.

gaurav rai
  • 103
  • 2
  • 11
  • I have already tried changing it. It still shows the same result. It gets shared but the twitter cards are not loading. So in my tweet I only see the url without any image, title or description as it should be. – Sayantan Mitra Sep 11 '17 at 10:39
  • See my latest edit. I tried it as you said but still no luck – Sayantan Mitra Sep 11 '17 at 10:48
  • @SayantanMitra, can you provide me the final url? – gaurav rai Sep 11 '17 at 10:56
  • http://quanutrition.com/Dotcom/new/Testimonials See the testimonials there? I want to share those testimonials on clicking the tweet button not the enitre page. – Sayantan Mitra Sep 11 '17 at 11:00
  • when i hit one of your twitter url "http://quanutrition.com/Dotcom/new/index.php/Testimonials/fb_share/1", it redirect me to "http://www.quanutrition.com/Dotcom/new/". I think that's why it was unable to pick right information on twitter. – gaurav rai Sep 11 '17 at 11:11
  • I will tell you what is happening - the functionality part. When the user clicks on the link a view file named as intermediate.php will be loaded. In that file in the header section all the Twitter Card tags are writrten. And as it reaches the body it will be redirected to the quanutrition.com/Dotnew/new page. The idea is to make Twitter take the meta tags from intermediate.php page before redirecting to quanutrition.com/Dotnew/new page. – Sayantan Mitra Sep 11 '17 at 11:19
  • 2
    No, this is wrong approach, twitter read your final output page, not intermediate page. – gaurav rai Sep 11 '17 at 11:58
  • I placed the meta tags in the header section of the final page. Still no result. For some reason twitter is not able to read the Twitter cards. I am not understanding the reason for it. – Sayantan Mitra Sep 11 '17 at 12:12