I want to use regular share button like on this page https://twitter.com/about/resources/buttons#tweet but to add an embedded image from my site, not just link.
I know all about 1.1 api and uploading, but making an tw application and then ask visitor on my site to give permission to write on his timeline just to share one pic from my site is not likely scenario, so I think about alternatives.
I've noticed when just paste links of pic that are already uploaded on twitter into tweet, if you paste link like https://pbs.twimg.com/media/BPpk_KUCMNBXsPN.jpg that is not going to be embeded, but if you paste link like this pic.twitter.com/NuDSx1ZKwy it will be embeded. So I think if I make profile and app that will call https://upload.twitter.com/1/statuses/update_with_media.json and upload pic, and then paste link in share button I will get tweet with pic embeded. Or there is better way? I use php.
Look into twitter cards.
The trick is not in the button but rather the page you are sharing. Twitter Cards pull the image from the meta tags similar to facebook sharing.
Example:
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:site" content="#site_username">
<meta name="twitter:title" content="Top 10 Things Ever">
<meta name="twitter:description" content="Up than 200 characters.">
<meta name="twitter:creator" content="#creator_username">
<meta name="twitter:image" content="http://placekitten.com/250/250">
<meta name="twitter:domain" content="YourDomain.com">
To create a Twitter share link with a photo, you first need to tweet out the photo from your Twitter account. Once you've tweeted it out, you need to grab the pic.twitter.com link and place that inside your twitter share url.
note: You won't be able to see the pic.twitter.com url so what I do is use a separate account and hit the retweet button. A modal will pop up with the link inside.
You Twitter share link will look something like this:
Share on Twitter
You're right in thinking that, in order to share an image in this way without going down the Twitter Cards route, you need to to have tweeted the image already. As you say, it's also important that you grab the image link that's of the form pic.twitter.com/NuDSx1ZKwy
This step-by-step guide is worth checking out for anyone looking to implement a 'tweet this' link or button: http://onlinejournalismblog.com/2015/02/11/how-to-make-a-tweetable-image-in-your-blog-post/.
You can create an href link like this:
Click to tweet
You can grab the image link if it has been tweeted first.
Go to the tweet, click on options & click Embed tweet. You will find the image link in the Embed tweet.
I used this code to solve this problem.
<img src="path_to_my_image"/>
You can check the tweet-button documentation here tweet-button
Using Javascript to create a twitter button, I use Fontawesome's classes for fetching the design. Remember to add the Fontawesome script in your HTML head.
let twitter_btn = document.createElement("i")
twitter_btn.className = "fa-brands fa-twitter-square fa-xl"
twitter_btn.setAttribute("index", array_index)
element.appendChild(twitter_btn)
twitter_btn.addEventListener("click", () => {
let url = "https://twitter.com/intent/tweet?url=" + params.url +
"&text=" + params.text
window.open(url)
})
Related
I have added necessary meta tags for twitter cards and Cardtype is 'summary'.
when I try to tweet any URL it does not follow CARD meta tags (OGP) for the link first Time. and it just shows as it is. now when I try same link again it works fine and shows expected result.
I tried this with another websites too.. It behaves the same?
Is there any reason behind this? Why I can't see the effect of Twitter CARD for the 1st time I try any link?
I'm trying to share some images via the Facebook sharer url "https://www.facebook.com/sharer/sharer.php".
The images are stored in the cloud in azure blobs, so I have a url that looks like "https://myapp.blob.core.windows.net/xxxx.gif"
In order for the Facebook sharer to correctly display the image it's looking for some meta tags, like "<meta property="og:image" content="http://ia.media-imdb.com/rock.jpg"/>"
What would be the best way to add those tags to cloud hosted images?
Options 1
Build a redirect url that takes the id of image adds the tags then redirects to the cloud url?
Any other ideas? Would option 1 work?
You're confusing two different things. The meta tags are for web pages, where if just the link to the page is shared, Facebook can then inspect the page and create a rich representation of it in the post by relying on those tags.
If you need to share a link that happens to be to an image, then you can't use meta tags. However, you might be able to use share intents to add some context to the link. For example, if you wanted to provide a link on a web page that will allow people to share the link to the image, you could do something like:
https://www.facebook.com/dialog/feed?app_id=[appId]&link=[url]&picture=[imageUrl]&name=[imageName]&caption=[imageCaption]&description=[imageDescription]&redirect_uri=[redirectUri]
That would take the user to a dialog that would allow them to make a post to their Facebook account, with all the provided information prepopulated. The redirect_uri tells Facebook where to send them back on your site when done posting.
First of all, please note that I searched for a SocialMediaStackExchange to ask this question on, but there doesn't seem to be one.
Here's what I'm wondering. When posting a tweet to twitter, if it is a youtube link or specific web site's link, then twitter will show an Expand functionality which the user can click to preview the media content right in the Twitter interface.
Does anyone know if this is determined by Twitter or if there is some way I can alter my web site to enable the preview on twitter?
I'd like to make it so when I tweet a blog entry that people can preview the first bit of contents of the article.
Here's an example: (simply adding the link, displays the preview content shown) In this case it is an article on InfoWorld.
There's a link on Twitter that explains Expanded Content, but not how to make it happen.
https://blog.twitter.com/2012/experience-more-with-expanded-tweets
You probably want to look at "Twitter Cards". They're really simple to set up. You add a few lines of code to your page's header, get your site validated (an automated process), and you're away.
Here, for example, is one of my tweets with "preview" content https://twitter.com/edent/status/516544061495193601
The extra HTML code is just:
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:creator" content="#edent">
<meta name="twitter:site" content="#edent">
<meta name="twitter:title" content="Tim Berners-Lee and the Freedom of The City">
<meta name="twitter:description" content="Last week, I had the privilege of being invited into the Guildhall to watch Tim Berners-Lee receive the Honorary Freedom of the City. I was one of a dozen bloggers and tweeters asked to live tweet th">
<meta name="twitter:image:src" content="https://shkspr.mobi/blog/wp-content/uploads/2014/09/TimBL-Least-Well-Dressed-435x375.jpg">
<meta name="twitter:image:width" content="280">
<meta name="twitter:image:height" content="150">
Different styles of cards have different sorts of previews - video, images, app installs, etc.
Also, I will point one important thing. For twitter:image meta its content parameter must be absolute path, not relative. Otherwise it will not work.
<meta name="twitter:image content="/resource/img.jpg"/> //will not work
<meta name="twitter:image content="https://yourdomain.com/resource/img.jpg"/> //will work
Is it possible to have a custom share image for Facebook, Google+ and Twitter?
I've already set up the open graph tags in the head of the document.
Thanks
UPDATE:
For Facebook:
<a href="http://www.facebook.com/share.php?u=url" target="_blank" ><img src="fb-img"/></a>
For Twitter:
<img src="twitter-img" />
Still looking for google+
By the way, any difference with sharer.php v/s share.php for Facebook?
I found the best solution to implement custom share button with Facebutton:
Go to facebook developers page and there you will have to read the following article which will explain you how to use meta tags (HTML) on the head of your page:
https://developers.facebook.com/docs/sharing/webmasters
Basically you need to add a Share Button on your page, right?. So, what you need to do is first of all, add the meta tags that page ask you for on the head of your page. Then everything is so easy. After facebook provides you with the code for the share button, now when you click on it, it will show you the image you specified on your meta tags. Take a look at that page and you'll see how easy is to implement it.
Twitter still i haven't implement it yet neither for google :(
I am having that problem that I got some items on a list that needs a like button.
That means I got multiple items on a page. I want to show an unique image and text when a user press like. The problem is that facebook meta tags goes in the header and it is only for the page. That means that the facebook like images are the same for all items. I have read this guide http://hillarsaare.com/multiple-facebook-like-buttons-on-one-page/ how to create multiple facebook likes with unique images and links. But my link that the user likes is a link that is been redirected in my controller to an external URL without any view.
Where should I place the meta tags? Should I create an view for my link ? How should I make an delay on the link that is been redirected?
I made a show file for my link. And but the facebook meta tags in the header, and some javascript to make the redirecet to my external link. In that way I can have multiple like buttons on a page with unique like information and images.