douchujian8124 2012-01-22 09:31 采纳率: 100%
浏览 37

php file_get_contents直接工作但不通过ajax和我的网址

I have the following code to get the facebook comments for my sites url:

<?php
$url="http://developers.facebook.com/blog/post/472";
$request_url ="https://graph.facebook.com/comments/?ids=".$url;
$requests = file_get_contents($request_url);
print_r($requests);
?>

The above works fine using the sample url that facebook provide in their tutorial. I can load the page above directly or through ajax and all is good.

The problem only arises for my url and specifically when loading it using ajax. If I load the page directly it works fine, but why when I try and load it through ajax do I get:

function.file-get-contents: failed to open stream: HTTP request failed! HTTP/1.0 500 Internal Server Error

  • 写回答

1条回答 默认 最新

  • doumao9363 2012-01-22 09:45
    关注

    As a security precaution, most production PHP servers should have

    allow_url_fopen = Off
    

    set to off. This would cause your script to fail like you're seeing it.

    Instead, use CURL. See http://snipplr.com/view/4084/

    评论

报告相同问题?

悬赏问题

  • ¥15 华为ensp模拟器中S5700交换机在配置过程中老是反复重启
  • ¥15 java写代码遇到问题,求帮助
  • ¥15 uniapp uview http 如何实现统一的请求异常信息提示?
  • ¥15 有了解d3和topogram.js库的吗?有偿请教
  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计