duanhe1976 2010-09-23 17:13
浏览 41
已采纳

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

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.

  • 写回答

3条回答 默认 最新

  • dongliqin6939 2010-09-23 19:18
    关注

    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();
    }
    ?>
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥15 使用ue5插件narrative时如何切换关卡也保存叙事任务记录
  • ¥20 软件测试决策法疑问求解答
  • ¥15 win11 23H2删除推荐的项目,支持注册表等
  • ¥15 matlab 用yalmip搭建模型,cplex求解,线性化处理的方法
  • ¥15 qt6.6.3 基于百度云的语音识别 不会改
  • ¥15 关于#目标检测#的问题:大概就是类似后台自动检测某下架商品的库存,在他监测到该商品上架并且可以购买的瞬间点击立即购买下单
  • ¥15 神经网络怎么把隐含层变量融合到损失函数中?
  • ¥15 lingo18勾选global solver求解使用的算法
  • ¥15 全部备份安卓app数据包括密码,可以复制到另一手机上运行
  • ¥20 测距传感器数据手册i2c