Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
973 views
in Technique[技术] by (71.8m points)

get json using php

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

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 ;

*/

?>
See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

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

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...