Jake Wilson
Jake Wilson

Reputation: 91213

Twitter web intent to post image?

Is it possible to attach an image to a tweet via Twitter's Web Intents? Right now, if you put an image in the message, the full URL of the image is put into the message, instead of the shortened and attached image URL...

https://twitter.com/intent/tweet?original_referer=http%3A%2F%2Fwww.website.com%2F&text=MyText+http%3A%2F%2Fwww.website.com%2Fimg%2Fimage.png&url=www.someurl.com

Click here to see the result (no attached image, just a full image url in the message....)

When you paste in an image URL into a tweet on Twitter.com, the image URL is automatically shortened and the image is attached to the tweet, so it shows the image when you view the tweet. I'm looking for something similar with the Web Intents.

Upvotes: 30

Views: 35102

Answers (3)

Josh D.
Josh D.

Reputation: 1326

First, you will need to post the image in a tweet to twitter.

Next, go to the tweet URL. It will be something like https://twitter.com/yourtwitterhandle/status/783356010631016448. View the source for that page and search for pic.twitter.com. You'll find a link to a URL that looks like pic.twitter.com/JvCvCquBlf.

Simply add that link to the content of your web intent URL and it will display when the user posts. It won't share in the tweet preview screen, but once they click 'tweet', it will be added

enter image description here

Example URL: https://twitter.com/intent/tweet?url=https%3A%2F%2Fwww.dataquest.io%2Fblog%2Fpython-pandas-databases%2F&via=dataquestio&text=Working%20with%20SQLite%20Databases%20using%20Python%20and%20Pandas%20pic.twitter.com/JvCvcquBlf&hashtags=sql%2CDataScience&

Upvotes: 12

dang
dang

Reputation: 1588

You have to use twitter card:https://dev.twitter.com/cards/overview. make sure you use the summary card and not the photo card which has deprecated. here is how you do it:

       <meta name="twitter:card" content="summary" />      
       <meta name="twitter:site" content="@tapaway" />
       <meta name="twitter:title" content="bla bla" />
       <meta name="twitter:description" content="bla bla" />
       <meta name="twitter:image" content="http://www.tapawayapp.com/assets/images/share.png" />
       <meta name="twitter:url" content="https://tapaway.parseapp.com//share.html" />

you can test yor cards here:https://cards-dev.twitter.com/validator

Upvotes: 3

Terence Eden
Terence Eden

Reputation: 14334

You can not attach an image, but you can use a Twitter Card.

With Twitter Cards, you can attach rich photos, videos and media experience to Tweets that drive traffic to your website.

Essentially, you need to add some metadata to your page. When Twitter sees that, it will automatically insert an image into the Tweet.

For a single photo, you would need to put this code on each page (put in your own details)

<meta name="twitter:card" content="photo" />
<meta name="twitter:site" content="@example" />
<meta name="twitter:title" content="My picture" />
<meta name="twitter:description" content="A description" />
<meta name="twitter:image" content="http://example.com/test.jpg" />
<meta name="twitter:url" content="http://example.com/mypage.html" />

Upvotes: 15

Related Questions