Facebook像按钮忽略URL参数 [英] Facebook like button ignore URL parameters
问题描述
这是我的代码:
pre>
< style type =text / css>
.float-all {
float:left;
width:82px;
height:30px;
overflow:hidden;
margin:2px;
padding:4px 2px;
}
.post-btn-share {
width:100%;
溢出:auto;
}
< link rel =canonicalhref =http://mypage.com/view_photo.php/>
< / head>
< div class =post-btn-share>
< div class =addthis_toolbox addthis_default_style>
< div class =float-all>
< iframe src =http://www.facebook.com/plugins/like.php?href=http://mypage.com/view_photo.php?img = 32& user = 1& xx = & send = true& layout = standard& width = 300& show_faces = true& action = like& colorscheme = light& font& height = 80frameborder =0style =border:none; scrolling =nowidth =320height =240>< / iframe>
< div class =float-all>
< / div>
< div class =float-all>
< / div>
< / div>
<?php
session_start();
?>
< div class =dev-ajuste>
<?php
require_once('script / require_raiz.php');
$ login = new login();
$ login-> log_isset();
// $ login-> info_user();
$ janela = new Janelas('script / system / config.ini','perfil');
$ janela-> info_visualiza_foto($ _ GET ['img'],$ _ GET ['user']);
?>
< / div>
<! - =======Cabeçalhoe chamadas de scripts do documento ======= - >
<?php include_once(head.php); ?>
<! - ======= Barra denavegação======= - >
<?php include_once(navbar.php); ?>
< div id =janelaclass =perfil>< / div>
< div id =infoclass =<?php echo $ _GET ['user'];?>>< / div>
<! - =======标题======= - >
<?php include_once('box_foto.php'); ?>
<! - =======宣传======= - >
<?php include('addsense.php');?>
<! - =======Áreados posts ======= - >
<?php include('post_area.php');?>
<! - =======Rodapédo documento ======= - >
<?php include_once(footer.php); ?>
<! - ======= Seguranca de Login ======= - >
/ p>
我真的不认为你已经理解了。查看iframe中使用的URL:
http://www.facebook.com/plugins/like.php? HREF = HTTP://mysite.com/view_photo.php IMG = 34&安培;用户= 1&安培; XX =&安培;;发送=真安培;;布局=标准&安培;;宽度= 300安培;; show_faces =真安培;;行动=像&安培;; colorscheme = light& ;; font& ;; height = 80
在一个URL中,资源从?
字符处开始。但是你有两个?
字符。参数是从第一个还是第二个开始的?解析器无法知道。当遇到&
时,是为外部URL分隔一个参数(第一个?
)还是一个被内部URL(第二个?
)封闭?解析器无法知道。
格式需要如下所示:
http:// someresource?parameter1& parameter2& etc
如果其中一个参数也是一个带有自己的参数的网址,整个参数需要进行网址编码,因此不会混淆网址的其余部分作为参数使用。任何解析器都必须能够清楚地标识出内部URL的内容以及外部URL的内容。当它需要使用它时,它会为你的内部URL解码。
PHP提供一个函数来做到这一点。 JavaScript也是如此。你可以使用任何你想要的。你所要做的就是传递要编码的字符串(这将是你的内部URL和任何需要到达该URL的参数),它将返回编码字符串(这将是发送到外部URL的参数)。
(另外,为什么你有所有这些分号?你没有用分号分开URL参数,我不确定你有什么想法。 )
I'm trying to like my page but the url parameters are ignored
Here is my code:
<style type="text/css">
.float-all {
float: left;
width: 82px;
height: 30px;
overflow: hidden;
margin: 2px;
padding: 4px 2px;
}
.post-btn-share {
width: 100%;
overflow: auto;
}
<link rel="canonical" href="http://mypage.com/view_photo.php" />
</head>
<div class="post-btn-share">
<div class="addthis_toolbox addthis_default_style">
<div class="float-all">
<iframe src="http://www.facebook.com/plugins/like.php?href=http://mypage.com/view_photo.php? img=32&user=1&xx=&send=true&layout=standard&width=300&show_faces=true&action=like&colorscheme=light&font&height=80" frameborder="0" style="border:none;" scrolling="no" width="320" height="240"></iframe>
<div class="float-all">
</div>
<div class="float-all">
</div>
</div>
And view_photo code
<?php
session_start();
?>
<div class="dev-ajuste">
<?php
require_once('script/require_raiz.php');
$login = new login();
$login->log_isset();
//$login->info_user();
$janela = new Janelas('script/system/config.ini','perfil');
$janela->info_visualiza_foto($_GET['img'],$_GET['user']);
?>
</div>
<!--=======Cabeçalho e chamadas de scripts do documento=======-->
<?php include_once("head.php"); ?>
<!--=======Barra de navegação=======-->
<?php include_once("navbar.php"); ?>
<div id="janela" class="perfil"></div>
<div id="info" class="<?php echo $_GET['user'];?>"></div>
<!--=======Header=======-->
<?php include_once('box_foto.php'); ?>
<!--=======Propaganda=======-->
<?php include('addsense.php');?>
<!--=======Área dos posts=======-->
<?php include('post_area.php');?>
<!--=======Rodapé do documento=======-->
<?php include_once("footer.php"); ?>
<!--=======Seguranca de Login=======-->
(Turning a comment chain into a potential answer)
I really don't think you've understood. Look at the URL being used in the iframe:
http://www.facebook.com/plugins/like.php?href=http://mysite.com/view_photo.php?img=34&user=1&xx=&;send=true&;layout=standard&;width=300&;show_faces=true&;action=like&;colorscheme=light&;font&;height=80
In a URL, parameters being sent to the resource start at the ?
character. But you have two ?
characters. Do the parameters start at the first one or the second one? A parser has no way to know. When a &
is encountered, is that separating a parameter for the outer URL (the first ?
), or one being enclosed with the inner URL (the second ?
)? A parser has no way to know.
The format needs to be like this:
http://someresource?parameter1¶meter2&etc
If one of those parameters is also a URL with its own parameters, that entire parameter needs to be URL-encoded so it doesn't confuse the rest of the URL for which it's being used as a parameter. Any parser has to be able to clearly identify what goes with the inner-URL and what goes with the outer-URL. It will URL-decode the inner one for you when it needs to use it.
PHP provides a function to do this. So does JavaScript. You can use whichever you'd like. All you do is pass it the string to be encoded (which would be your inner URL with whatever parameters need to go to that URL) and it will return the encoded string (which would be the parameter to send to your outer URL).
(Also, why do you have all those semi-colons? You don't separate URL parameters with semi-colons. I'm not sure where you got that idea.)
这篇关于Facebook像按钮忽略URL参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!