0

I have a question, is it possible to have the contents of a file from github? I have a file on github and I created a function to retrieve the contents of this file but it does not work.

Here is my function:

function process_import_file( $file ) {

    // File exists?
    if ( ! file_exists( $file ) ) {
        return;
    }

    // Get file contents and decode.
    $data = wp_remote_get( $file );
    $data = json_decode( $data );

    $this->import_data( $data );
}

The url github is like this: https://raw.githubusercontent.com/name/repo/master/file.json

When I open it in my browser, the content is displayed.

Can you help me?

Thank you a lot :)

Nick
  • 11
  • 3
  • Does this help http://stackoverflow.com/q/4604663/1375964 – osowskit Nov 18 '16 at 20:39
  • Hello, thank you very much for the url, unfortunately it does not help because I am at the same point. I would like to know how to do (if possible) to have the contents of a file with the url "raw.githubusercontent.com". When I place the file locally, it works very well. – Nick Nov 18 '16 at 21:29

0 Answers0