gitee-php/gitee-sdk

v5.6.0 2024-08-07 01:48 UTC

This package is auto-updated.

Last update: 2024-09-07 02:03:30 UTC


README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

PHP的Gitee SDK (由Swagger Codegen生成 https://github.com/swagger-api/swagger-codegen)

需求

PHP 5.5 及以上版本

安装与使用

Composer

composer require gitee-php/gitee-sdk

手动安装

下载文件并包含 autoload.php

require_once '/path/to/vendor/autoload.php';

入门指南

请遵循安装流程,然后运行以下命令

<?php
require_once __DIR__ . '/vendor/autoload.php';

$apiInstance = new Gitee\Api\ActivityApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
    new GuzzleHttp\Client()
);
$owner = "owner_example"; // string | 仓库所属空间地址(企业、组织或个人的地址path)
$repo = "repo_example"; // string | 仓库路径(path)
$accessToken = "accessToken_example"; // string | 用户授权码

try {
    $apiInstance->deleteV5UserStarredOwnerRepo($owner, $repo, $accessToken);
} catch (Exception $e) {
    echo 'Exception when calling ActivityApi->deleteV5UserStarredOwnerRepo: ', $e->getMessage(), PHP_EOL;
}

?>

警告

由于 Gitee 官方提供的 swagger.json 存在错误,因此本 SDK 中部分 API 的返回值 Model 未能正确返回内容。如果发现,可以提交 问题 或提交 Pull Request
同时,为了减小影响,可以使用 SDK 提供的 ResponseHandler 来获取原始响应。

<?php
require_once __DIR__ . '/vendor/autoload.php';

$response = new Gitee\ResponseHandler();
$client = $response->createClientWithMiddleware();

$apiInstance = new Gitee\Api\UsersApi($client);
$accessToken = "accessToken_example"; // string | 用户授权码

try {
    $result = $apiInstance->getV5User($accessToken);
    print_r($result);
    print_r($response->toArray());
} catch (Exception $e) {
    echo 'Exception when calling UsersApi->getV5User: ', $e->getMessage(), PHP_EOL;
}

?>

API端点文档

所有URI均相对于 https://gitee.com/api

模型文档