Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7885979
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T05:12:23+00:00 2026-06-03T05:12:23+00:00

I parse a parameter to a php file and try to get json with

  • 0

I parse a parameter to a php file and try to get json with file_get_contents().
This is my Code:

< ?php
    $url = $_GET['url'];
    $url = urldecode($url);
    $json = file_get_contents($url, true);
    echo($json);
? >

This is the called URL:
http://vimeo.com/api/v2/channel/photographyschool/videos.json

This is a part of my result:

[{"id":40573637,"title":"All For Nothing - \"Dead To Me\" & \"Twisted Tongues\""}]

And so on… So everything is escaped. There are even \n in the result.

Since I neet to work afterwards with the json (in js), I need a non escaped version!

Interesting thing is, that my code works for example with this json:
http://xkcd.com/847/info.0.json

What is my problem?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T05:12:24+00:00Added an answer on June 3, 2026 at 5:12 am

    If you just want to proxy/forward the response then just echo it as it is with the correct Content-Type header:

    <?php
        header('Content-Type: application/json');
        $json = file_get_contents('http://vimeo.com/api/v2/channel/photographyschool/videos.json');
        echo $json;
    ?>
    

    Tho you have to be very wary of the url passed as it could cause XSS!

    And as the API is slow/resource hungry you should cache the result or at least save it in a session so its not repeated on each page load.

    <?php
    $cache = './vimeoCache.json';
    $url = 'http://vimeo.com/api/v2/channel/photographyschool/videos.json';
    
    //Set the correct header
    header('Content-Type: application/json');
    
    // If a cache file exists, and it is newer than 1 hour, use it
    if(file_exists($cache) && filemtime($cache) > time() - 60*60){
        echo file_get_contents($cache);
    }else{
        //Grab content and overwrite cache file
        $jsonData = file_get_contents($url);
        file_put_contents($cache,$jsonData);
        echo $jsonData;
    }
    ?>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$(document).ready(function() { $.ajax({ method: get, url: 'ctr_seearmylist.php', dataType: 'json', data: 'get=squad', success: processSquads() });
I am using php to parse an XML file, but I get an error
I parse data using JSON in javascript, I find this is very convenient. But
Shortened Aim: To pass a variable via $.POST to a PHP file (get.php), and
I am trying to parse an XML file from a URL by taking all
I have this problem where all URLs like context/path/file/anything/that/follows becomes context/path/file.php/anything/that/follows or context/path/file.xml/anything/that/follows .
How do I parse URL parameters in JavaScript? (These are the parameters I would
Parse error: syntax error, unexpected '?' error points to after .css : echo '<fb:recommendations
I parse some values from an xml file. There is a @25-12-2010'T'23:40:00 string with
Environment: PHP 5.3 I'm trying to write my own query parameter substitution method. Basically

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.