1213
1213

Reputation: 756

Include GitHub files into a remote website

What is the easier way to embed a GitHub README.md file into a remote website?

I would love to have a synchronized copy of the README file on a web page, I think GitHub pages don't allow users to do so, and I didn't find my answer in the GitHub API. Any idea?

Upvotes: 3

Views: 1364

Answers (3)

Mads
Mads

Reputation: 724

Take a look at https://developer.github.com/v3/git/blobs/

You can both retrieve and create blobs.

Upvotes: 1

1213
1213

Reputation: 756

This can be a solution to my problem: Using the GitHub API and PHP to Get Repository Information, and here is a working demo.

Upvotes: 1

Learath2
Learath2

Reputation: 21403

Depends on what kind of a copy you want if you want a file copy like in example.com/project/README.md or something displayed on a php page. If what you want is the first you can make a php script to fetch the file to your server. But if you want to have it on a php page you can use something like :

<?php
$url = "https://raw.github.com/USER/PROJECT/README.md";
$readme = file_get_contents($url);

print $readme;
?>

And this would be the fetch script I mentioned earlier

<?php
$url = "https://raw.github.com/USER/PROJECT/README.md";
$readme = file_get_contents($url);

$file = fopen('README.md','w');
fputs("$file","$readme");
fclose($file);
?>

Upvotes: 1

Related Questions