向另一个具有针对我的原始页面的回调的网站发送请求

发布于 2024-09-24 12:38:20 字数 480 浏览 1 评论 0原文

在我的 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

默嘫て 2024-10-01 12:38:20

其丑陋。

这两个发布的解决方案不起作用,因为:

  • 重定向时引用者不会更改(如果是 http 元重定向,则它会被清除,但如果是标头重定向,则不会。但它不会变得那么容易)。< /p>

  • 如果之后有其他正常执行的事情,那么将退出放在发送的标头之后通常是一个好主意,但这与问题无关。

简而言之,如果应该是相同页面,则需要存储在文件或数据库中,或者存储在每个 ip 地址/用户的重定向计数和中断或之外的内容中> 这个确实可靠。您可以通过拥有无法逆向工程等的安全令牌来使其更加安全,但这一切都没有意义。您还可以使用cookie。这同样不可靠。

关于您的问题,flickr 不会重定向回相同的年龄。
关于它们的规格,它们附加了 ?frob=[frob]。
http://www.flickr.com/services/api/auth.spec.html检查

一下:

    <?php 
if(!isset($_GET["frob"])) {
header("Location: " . $request);
exit();
}
?>

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:

    <?php 
if(!isset($_GET["frob"])) {
header("Location: " . $request);
exit();
}
?>
深居我梦 2024-10-01 12:38:20

尝试使用 $_server['HTTP_REFERER'] 检查 referer

[已编辑]

我只是想说,您应该尝试添加 if 条件

// just and example, use some regular expression to check the refere
if($_SERVER['HTTP_REFERER'] != http://flicker.com){ 
header("Location: " . $request);
}else{
 // another code
}

谢谢

try checking the referer with the $_server['HTTP_REFERER']

[Edited]

I just wanted to say that, you should try adding if condition

// just and example, use some regular expression to check the refere
if($_SERVER['HTTP_REFERER'] != http://flicker.com){ 
header("Location: " . $request);
}else{
 // another code
}

Thanks

挽袖吟 2024-10-01 12:38:20

作为检查 $_GET["frob"] 是否(不)存在的替代方法,您不能将 Flickr 中的回调 URL 设置为 www.mysite.com/test.php?from_flickr=1< /code> 然后做

if (!$_GET['from_flickr']) {
    header('Location: '.$request);
    exit; 
}

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

if (!$_GET['from_flickr']) {
    header('Location: '.$request);
    exit; 
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文