[英]How to download GitHub repository as zip archive using PHP api?
我正在嘗試使用php API以zip格式下載Github存儲庫。 誰能幫我解決這個問題?
你可以試試
file_put_contents("master.zip",
file_get_contents("https://github.com/{group}/{project}/archive/master.zip")
);
但是,請確保在php.ini
設置了allow_url_fopen
,那么您可以輕松使用file_get_contents()
您可以將以下兩個拼圖組合在一起:
php下載文件: https : //stackoverflow.com/a/3938551/2536029
github zips: https : //github.com/ $ USER / $ REPO / archive / $ BRANCH.zip例如https://github.com/bpowers/psm/archive/master.zip
首先,使用以下格式構建網址: https : //api.github.com/repos/ : owner/ : repo/ : archive_format/ : ref
然后,使用curl訪問該URL,但不要忘記執行以下操作:
抱歉,沒有示例代碼,但是說明很清楚。 有用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.