Reputation: 756
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
Reputation: 724
Take a look at https://developer.github.com/v3/git/blobs/
You can both retrieve and create blobs.
Upvotes: 1
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
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