dongrouyuan5685 2012-08-20 15:39
浏览 90

Joomla模块开发 - 从存储在模块文件夹中的文件读取/处理JSON数据

I am in the process of developing a module that requires JSON data stored on a file within the folders of the module.

Initially I was using a link to the remote JSON file and that worked fine... until I realised that using this method doesn't work on certain servers configurations and causes issues with certain versions of jquery and IE.

The obvious solution to this issue is to read the file locally within the joomla module however I am getting 403 Forbidden errors on the php file that is serving the json data (see below).

The file with the JOSN data is a php file with this code:

$json = file_get_contents('https://www.googleapis.com/webfonts/....');
die($json);

I am calling the JSON file using jQuery:

$.getJSON('....', function (json) {....}

Would anybody know how to go around this issue? Thank you in advance for the help.

  • 写回答

1条回答 默认 最新

  • drydaenth257216154 2012-11-03 14:44
    关注
    $json = file_get_contents(JPATH::base() . 'modules/my_module/myfilewithjson.php');
    echo $json;
    exit();
    

    if the file is not local then you should be using curl to get the contents.

    评论

报告相同问题?

悬赏问题

  • ¥20 docker里部署springboot项目,访问不到扬声器
  • ¥15 netty整合springboot之后自动重连失效
  • ¥15 悬赏!微信开发者工具报错,求帮改
  • ¥20 wireshark抓不到vlan
  • ¥20 关于#stm32#的问题:需要指导自动酸碱滴定仪的原理图程序代码及仿真
  • ¥20 设计一款异域新娘的视频相亲软件需要哪些技术支持
  • ¥15 stata安慰剂检验作图但是真实值不出现在图上
  • ¥15 c程序不知道为什么得不到结果
  • ¥15 键盘指令混乱情况下的启动盘系统重装
  • ¥40 复杂的限制性的商函数处理