向另一个具有针对我的原始页面的回调的网站发送请求
在我的 test.php 文件中,我向我使用的 Flickr 应用程序发送了一个请求
header("Location: " . $request);
,其中 $request 是我尝试在 Flickr 上访问的 URL。
对于我的 Flickr 应用程序,我必须设置一个回调 URL。当 Flickr 处理完我的请求后,它将调用回调 URL。
我希望回调 URL 是我的原始页面 test.php。当我尝试这样做时,我陷入了无限循环,因为 test.php 正在将请求重新发送回 Flickr,而 Flickr 再次调用我的 test.php(无限重复,直到浏览器退出)。
有没有办法在 test.php 中添加某种条件来检查请求是否来自 Flickr,或者至少有某种方式让脚本知道请求已发送,因此不要再次发送。
我已经尝试过将回调 URL 更改为我的另一个页面,效果很好。我只是想看看是否可以重复使用同一页面。
In my test.php file, I sent a request to a Flickr app I have using
header("Location: " . $request);
where $request is the URL that I am trying to reach on Flickr.
For my Flickr app, I have to set a callback URL. When Flickr is done with processing my request, it will call the callback URL.
I would like the callback URL to be my original page, test.php. When I try this, I get stuck in an infinite loop, because test.php is re-sending the request back to Flickr, and Flickr calls my test.php again (repeat ad infinitum until the browser quits).
Is there a way to put some kind of conditional in test.php to check if the request came from Flickr, or at least some way to let the script know that the request has been sent, so don't send it again.
I've already tried it where I changed the callback URL to another page of mine, and that works fine. I'm just seeing if I could re-use the same page.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
其丑陋。
这两个发布的解决方案不起作用,因为:
重定向时引用者不会更改(如果是 http 元重定向,则它会被清除,但如果是标头重定向,则不会。但它不会变得那么容易)。< /p>
如果之后有其他正常执行的事情,那么将退出放在发送的标头之后通常是一个好主意,但这与问题无关。
简而言之,如果应该是相同页面,则需要存储在文件或数据库中,或者存储在每个 ip 地址/用户的重定向计数和中断或无之外的内容中> 这个确实可靠。您可以通过拥有无法逆向工程等的安全令牌来使其更加安全,但这一切都没有意义。您还可以使用cookie。这同样不可靠。
关于您的问题,flickr 不会重定向回相同的年龄。
关于它们的规格,它们附加了 ?frob=[frob]。
http://www.flickr.com/services/api/auth.spec.html检查
一下:
Its ugly.
The two posted solutions won't work because:
The referer isnt changed on redirect (well it is cleared if its a http meta redirect, but not if its a header redirect. but it doesnt become something else so easy).
Putting exiting after a sent header is generally a good idea if there is something else normaly executed afterwards, but its not related to the problem.
Simply put, if it should be the SAME page, you need to to store in a file or database or something the redirect counts per ip adress/user and break or something but NONE of this is really reliable. You can make it more secure by having a secured token that cannot be reverse engeneered etc but all this doesn't make sense. You could also use cookies. Which is just as unreliable as well.
Regarding your problem, flickr does NOT redirect back to the samep age.
Regarding to their specifications they append ?frob=[frob].
http://www.flickr.com/services/api/auth.spec.html
Check for that:
尝试使用
$_server['HTTP_REFERER']
检查referer
[已编辑]
我只是想说,您应该尝试添加
if 条件
谢谢
try checking the
referer
with the$_server['HTTP_REFERER']
[Edited]
I just wanted to say that, you should try adding
if condition
Thanks
作为检查 $_GET["frob"] 是否(不)存在的替代方法,您不能将 Flickr 中的回调 URL 设置为
www.mysite.com/test.php?from_flickr=1< /code> 然后做
As an alternative to checking for the (non-)existence of $_GET["frob"], couldn't you set the callback url in Flickr to be
www.mysite.com/test.php?from_flickr=1
and then do