[英]facebook share for custom parameters in a link
I am trying to share my custom link on facebook using this javascript function, 我正在尝试使用此javascript函数在Facebook上共享我的自定义链接,
function postToFacebook(title, summary, image_url, U)
{
window.open('http://www.facebook.com/dialog/feed?app_id= ' + fb_app_id + '&display=popup&caption=' + title + '&description='+ summary + '&redirect_uri=' + encodeURIComponent('http://facebook.com') + '&link=' + encodeURI(U) + '&picture=' + image_url,'sharer','toolbar=0,status=0,width=548,height=325');
}
In my "U" parameter I have this link => " http://localhost:4000/rings/solitaire-rings/lst?utf8=%E2%9C%93&min_price=&max_price=&name=solitaire-rings&category=rings&fashion_type=false&search=&gallery_order=&new_arrival=&best_seller=&metal_white=on&commit=APPLY " 在我的“ U”参数中,我具有此链接=>“ http:// localhost:4000 / rings / solitaire-rings / lst?utf8 =%E2%9C%93&min_price =&max_price =&name = solitaire-rings&category = rings&fashion_type = false&search = &gallery_order =&new_arrival =&best_seller =&metal_white = on&commit = APPLY “
and when user clicks on the link which is shared on facebook , user should get redirected to this link. 当用户单击在facebook上共享的链接时,应将其重定向到该链接。 forget about root url ie localhost:4000, because on production environment its considering required url.
忘记根URL,即localhost:4000,因为在生产环境中,它考虑了所需的URL。
the problem is that whne i am sharing this url on facebook user is getting redirected to " http://localhost:4000/rings/solitaire-rings/lst?utf8 ", and its not taking care of further parameters which are "%E2%9C%93&min_price=&max_price=&name=solitaire-rings&category=rings&fashion_type=false&search=&gallery_order=&new_arrival=&best_seller=&metal_white=on&commit=APPLY" 问题是,当我在facebook用户上共享此URL时,被重定向到“ http:// localhost:4000 / rings / solitaire-rings / lst?utf8 ”,并且它不处理其他参数“%E2” %9C%93&min_price =&max_price =&name =纸牌戒指&category =戒指&fashion_type = false&search =&gallery_order =&new_arrival =&best_seller =&metal_white = on&commit = APPLY“
basicaaly I supposed to get this URL " http://admin.velvetcase.com/rings/lst?utf8=%E2%9C%93&min_price=&max_price=&name=rings&fashion_type=false&search=&gallery_order=&new_arrival=&best_seller=&search_material_id[]=Diamond&commit=APPLY " , but when I am sharing mu URL on facebook I am getting this one " http://admin.velvetcase.com/rings/lst?utf8=%E2%9C%93&%3Bmin_price&%3Bmax_price&%3Bname=rings&%3Bfashion_type=false&%3Bsearch&%3Bgallery_order&%3Bnew_arrival&%3Bbest_seller&%3Bsearch_material_id[0]=Diamond&%3Bcommit=APPLY " , which is not giving e required output. 我基本上应该得到这个URL“ http://admin.velvetcase.com/rings/lst?utf8=%E2%9C%93&min_price=&max_price=&name=rings&fashion_type=false&search=&gallery_order=&new_arrival=&best_seller=&search_material_id[]=Diamond = APPLY “,但是当我在Facebook上共享mu URL时,我得到的是这个http://admin.velvetcase.com/rings/lst?utf8=%E2%9C%93&%3Bmin_price&%3Bmax_price&%3Bname=rings&% 3Bfashion_type = false&amp%3Bsearch&amp%3Bgallery_order&amp%3Bnew_arrival&amp%3Bbest_seller&amp%3Bsearch_material_id [0] = Diamond&amp%3Bcommit = APPLY “,这不会提供必需的输出。
Here is what I did successfully 这是我成功完成的工作
var sharingUrl = "https://www.facebook.com/dialog/feed?app_id="+ facebookAppID +
"&link=" + sharingUrl +
"&name=" + encodeURIComponent(title) +
"&caption=" + encodeURIComponent(caption) +
"&description=" + encodeURIComponent(content) +
"&picture=" + encodeURIComponent(thumb) +
"&redirect_uri=https://www.facebook.com";
window.open(sharingUrl);
For all parameters we need to use encodeURIComponent
, but I try to not use encodeURIComponent
for sharingUrl
, it still works! 对于所有参数,我们都需要使用
encodeURIComponent
,但是我尝试不要对sharingUrl
使用encodeURIComponent
,它仍然可以工作!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.