Score
0
Watch 6 Star 35 Fork 10

Hamm / Svg Badge ToolPHPMulanPSL-2.0

Join us
Explore and code with more than 5 million developers,Free private repositories !:)
Sign up
Svg Badge Tool是一个快速生成SVG的小工具,支持传入参数进行生成svg的可外链小图标。 spread retract

https://svg.hamm.cn

Clone or download
gitee.php 1.62 KB
Copy Edit Web IDE Raw Blame History
Hamm authored 2020-04-27 23:00 . 修改curl为直接请求API
<?php
require_once('common.php');
if(empty($_GET['user']) || empty($_GET['project']) || empty($_GET['type'])){
header('Location: https://gitee.com/hamm/svg_badge_tool');
die;
}
$user = trim($_GET['user'] ?? 'hamm');
$project = trim($_GET['project'] ?? 'svg_badge_tool');
$type = trim($_GET['type'] ?? 'star');
$key = 'Gitee';
$value = '';
$url = "https://gitee.com/api/v5/repos/".$user."/".$project;
$result = httpGetFull($url);
$giteeArray = json_decode($result,true);
switch($type){
case 'star':
if(array_key_exists('message',$giteeArray)){
$value = "? Stars";
}else{
$value = $giteeArray["stargazers_count"] . ' Stars';
}
break;
case 'fork':
if(array_key_exists('message',$giteeArray)){
$value = "? Forks";
}else{
$value = $giteeArray["forks_count"] . ' Forks';
}
break;
case 'watch':
if(array_key_exists('message',$giteeArray)){
$value = "? Watches";
}else{
$value = $giteeArray["watchers_count"] . ' Watches';
}
break;
case 'commit':
$url = "https://gitee.com/".$user."/".$project;
$urlForSvg = "https://gitee.com/".$user."/".$project."/commits/master";
try{
$html = httpGetFull($url);
if(preg_match('/icon-commit\'><\/i>\n<b>(.*?)<\/b>/', $html, $matches)){
$value = $matches[1]." Commits";
}else{
$value = "? Commits";
}
}catch(Exception $e){
$value = "? Commits";
}
break;
default:
}
require_once('svg.php');
?>

Comment ( 0 )

Sign in for post a comment

PHP
1
https://gitee.com/hamm/svg_badge_tool.git
git@gitee.com:hamm/svg_badge_tool.git
hamm
svg_badge_tool
Svg Badge Tool
master

Help Search

182353 aa51c838 1899542 205747 347fc4a1 1899542