在share .php中,无法访问与url一起传递的参数


In sharer.php , unable to acess the parameters passed with the url

我试图打开share.com php如下

http://www.facebook.com/sharer.php?u=http://mywebsite.com/index.php ? var1 = XYZ& var2 = ABC

当共享对话框打开时,var1在index.php中被访问,但var2不可访问:(

但是如果我打开

http://mywebsite.com/index.php?var1=XYZ& var2 = ABC

在新窗口,它很容易访问。

请帮助如何访问var2,而使用shareer .php ?

不要忘记对URL进行编码,参见本帖的答案:URL被编码错误

所以你必须用encodeURIComponent来编码它:

var url = 'http://www.facebook.com/sharer.php?u=' + encodeURIComponent('http://mywebsite.com/index.php?var1=XYZ&var2=ABC');