문제

I am using the following code to show a page with a Twitter box already filled in with a message:

<a href="http://www.twitter.com/share.php?url=http://myurl.com&text=myMessage" target="_blank">Click me</a>

However, on the page, I am getting this inside the Twitter box:

myMessage/

Note the trailing slash. Any ideas how to fix this?

도움이 되었습니까?

해결책

We have found a workaround for this, where you add the source=webclient parameter, crucially, to the END of the twitter address. When you do this, Twitter no longer adds the trailing slash. However, given how Twitter like to change their formats and codes around, there's no guarantee this will work forever :-)

For example...

<a href="https://twitter.com/intent/tweet?text=http://www.rsc.org%2FEducation%2FEiC%2Fissues%2F2013January%2F50th%2Delement%2Dtin%2Easp&amp;source=webclient" target="_blank">Twitter this</a>

다른 팁

No, the solution is more simple. URL-encode your url :

https://twitter.com/intent/tweet?text=myMessage&url=http%3A%2F%2Fmyurl.com

Add a trailing slash to your URL and that should go away. It worked for me.

Change the URL from this:

http://www.twitter.com/share?url=http://myurl.com&text=myMessage

To this:

http://www.twitter.com/share?url=http://myurl.com/&text=myMessage

As Twitter documentation claims (twitter original reference):

A fully-qualified URL with a HTTP or HTTPS scheme, URL-encoded.

Fully-qualified URL requires to have trailing slash. From the same documentation:

Example Value: http:%3A%2F%2Fexample.com%2F

Note, that the example has %2F at the end, which is HTML encoded / character. Twitter tries to create correct URL by appending / automatically.

Set your url GET parameter to http://myurl.com/ to get rid of the trailing slash

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top