We are implementing share functionality with TencentQQ using their static share URL. We have an encoded URL: "http://www.testurl.com/product/this-is-a-product-%E7%9F%AD%E8%A3%A4/id-000000"
When this link is shared via TencentQQ using this link: http://share.v.t.qq.com/index.php?c=share&a=index&url=http://www.testurl.com/product/this-is-a-product-%E7%9F%AD%E8%A3%A4/id-000000&title=This%20is%20a%20test&appkey=000000000
You will see on your feed that the URL is being split at the start of the Mandarin characters.
I imagine that they are using decodeURIComponent when processing the URL, which I notice has the same effect when executed in Chrome's dev tools console:
I guess the question here is -- am I doing something wrong in encoding this URL? Is there a reason that the URL is being split at the start of the Mandarin characters?
Your URL isn't encoded, it looks like it was encoded because it uses non-ASCII/non-Latin characters, any URL that has another URL inside as a parameter needs to be encoded, long story short, here is the solution:
function urlShare(url,title,appkey){
return 'http://share.v.t.qq.com/index.php?c=share&a=index&url='+encodeURIComponent(url)+'&title='+encodeURIComponent(title)+'&appkey='+appkey
}
Just call this function with the URL, Title and appkey (don't know if the appkey need to be encoded):
urlShare('http://www.testurl.com/product/this-is-a-product-%E7%9F%AD%E8%A3%A4','A Title','id-000000')
It will return a safe URL that actually works.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With