关于php:如何将这样的网址传递给Facebook

how to pass the url like this to facebook

问:如何将这样的网址传递给facebook。

https://www.facebook.com/sharer.php?t=XBOX


1
2
3
4
CLICK ME


function fbs_click() {u=location.href;t=document.title;window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');return false;}

#编码为%23,可以使用urlencode()

1
https://www.facebook.com/sharer.php?t=XBOX&u=http://aaa.com/%23/project/xbox-branding

,但是您应该像这样编码完整的重定向URL:

1
https://www.facebook.com/sharer.php?t=XBOX&u=http%3A%2F%2Faaa.com%2F%23%2Fproject%2Fxbox-branding

始终对URL进行编码以转义特殊字符。

在js中,

1
'https://www.facebook.com/sharer.php?t=XBOX&u=' + encodeURIComponent('http://aaa.com/#/project/xbox-branding');

在php中,

1
'https://www.facebook.com/sharer.php?t=XBOX&u='.urlencode('http://aaa.com/#/project/xbox-branding');


ans:将网址中的#更改为#。例如http://aaa.com /#/ project / ......