Title: Json file response
Last modified: July 14, 2018

---

# Json file response

 *  [jkepler](https://wordpress.org/support/users/jkepler/)
 * (@jkepler)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/json-file-response/)
 * Good evening.
 * I need some assistance if possible.
 * I have a script that asks for an url file, which is read with wp_remote_get
 * I’m trying to make that url point to a php file and return a json response as
   if it was a file.
 * So far, I was able to do it like this: I created an array, and after that I coded:
 *     ```
       header("Content-type:application/json"); 
       $out = json_encode($json, true); 
       echo $out; 
       ```
   
 * where $json was a php array. The problem is that it’s not working anymore – it
   was, but not now.
 * Any ideas please?
 * Kind regards
    -  This topic was modified 7 years, 10 months ago by [Steven Stern (sterndata)](https://wordpress.org/support/users/sterndata/).

Viewing 1 replies (of 1 total)

 *  Moderator [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * (@bcworkz)
 * [7 years, 10 months ago](https://wordpress.org/support/topic/json-file-response/#post-10495921)
 * Sending a proper Content-type header should be all that’s required, though I’ve
   heard IE has some issues with “application/json” MIME type. It supposedly can
   be fixed with a registry entry.
 * If this was once working and you’ve made no changes, the problem likely lies 
   elsewhere. Does requesting a static JSON file work correctly? You can try comparing
   the server response of a static file with that of the PHP file, maybe there’s
   something missing that’s critical for the requesting script. For example, a static
   file request will likely include caching data which are missing with a PHP request.
   If the script needs such information, you’d need to program the PHP response 
   to include such data. Data like last-modified and etag.

Viewing 1 replies (of 1 total)

The topic ‘Json file response’ is closed to new replies.

## Tags

 * [json](https://wordpress.org/support/topic-tag/json/)
 * [php](https://wordpress.org/support/topic-tag/php/)

 * In: [Developing with WordPress](https://wordpress.org/support/forum/wp-advanced/)
 * 1 reply
 * 2 participants
 * Last reply from: [bcworkz](https://wordpress.org/support/users/bcworkz/)
 * Last activity: [7 years, 10 months ago](https://wordpress.org/support/topic/json-file-response/#post-10495921)
 * Status: not resolved

## Topics

### Topics with no replies

### Non-support topics

### Resolved topics

### Unresolved topics

### All topics
