LoginSignup
13
11

More than 5 years have passed since last update.

php-qiita: Qiita API PHPライブラリ

Last updated at Posted at 2012-10-10

Qiita APIをPHPで扱うためのライブラリを作りました。GitHubで公開しています。

機能

今のところ

  • 認証
  • api() メソッドで情報取得・投稿などの各種APIを叩く

くらいのことはできます。

curl拡張が必須です。

インストール

Composer経由でインストールします。

まず composer.json ファイルに下記を記述します:

{
    "require": {
        "suin/php-qiita": "dev-master"
    }
}

composerを走らせてインストールします:

$ composer install

最後に、あなたのプロダクトで vendor/autoload.php をインクルードします:

require_once 'vendor/autoload.php';

使い方

<?php
$qiita = new Qiita(array(
    'username' => 'suin',
    'password' => 'p@ssW0rd',
));

try
{
    // ユーザ情報の取得
    $user = $qiita->api('/users/suin');

    // 投稿の実行
    $createdItem = $qiita->api('/items', 'POST', array(
        'title' => 'Qiita APIからのテスト投稿',
        'tags' => array(
            array('name' => 'Qiita'),
        ),
        'body' => 'テスト投稿',
        'private' => false,
    ));
}
catch ( Exception $e )
{
    error_log($e);
}

License

php-qiita is licensed under the MIT License - see the LICENSE file for details

13
11
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
13
11