使用php获取json [英] get json using php

查看:98
本文介绍了使用php获取json的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从中获取json数据, http://vortaro.us.to/ajax/epo/eng/ +'单词'+"/?callback =?" 工作示例(信誉不足)

I need to get the json data from, http://vortaro.us.to/ajax/epo/eng/ + 'word'+ "/?callback=?" working example (not enough reputation)

我知道如何用JavaScript做到这一点,但是我需要我的php文件来获取此数据,它需要是服务器端的,谢谢.我是新手,我已经花了整整一天的时间来弄清楚这一点. fopen和fread不起作用,

I know how to do it in javascript, But I need my php file to get this data, It needs to be server side, Thanks I'm new I have spent all day trying to figure this out. fopen and fread isn't working,

<?php
$vorto = $_GET['vorto']; // Get the Word from Outer Space and Search for it!

if (isset($vorto))
    {
    echo $vorto;
    } else {
        $Help = "No Vorto -> add ?vorto=TheWordYouWant to the end of this website";
        echo $Help;
    }
$url1 = "http://vortaro.us.to/ajax/epo/eng/"; 
$url2 = "/?callback=?";
$finalurl= $url1 . $vorto . $url2;

/*
PLEASE HELP

$v1 = fopen($finalurl ,"r");
echo $v1;


$frv1 = fread($v1,filesize($v1));
echo $frv1 ;

*/

?>

推荐答案

file_get_contents()可以使用在URL上.一种处理HTTP页面下载的简单便捷的方法.

file_get_contents() can be used on a URL. A simple and convenient way to handle http page download.

完成后,您可以使用 json_decode()来将数据解析为有用的内容.

That done, you can use json_decode() to parse the data into something useful.

这篇关于使用php获取json的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆