Help us understand the problem. What is going on with this article?

PHPでQiita APIv2のラッパを作ってみた

More than 1 year has passed since last update.

概要

Qiita APIv2のPHPラッパ。本当に元のAPIをラッピングしているだけ。
https://github.com/kuredev/qiita-php-wrapper

リファレンス

src/api.json に使える関数の一覧とQiita APIv2とのマッピングの情報がある
https://github.com/kuredev/qiita-php-wrapper/blob/master/src/api.json

動機

  • PHPの勉強
  • packagistに登録してみたかった

実装

以下のライブラリを使わせてもらった。
APIのラッピングの部分を、コードの外のファイルで管理できる。
あまり他に使われた実績が見当たらないけど、便利な気がする。
通信の部分はGuzzleが内部的に使われてる。

palanik/wrapi-php: Wrapper for calling Restful API https://github.com/palanik/wrapi-php

使い方

インストール

$ composer require kuredev/qiita-php-wrapper

使い方サンプル

<?php
require 'vendor/autoload.php';
$accessToken = "xxxxxxxxxxxxxx";

try{
    $qiita = new \Kuredev\Qiita($accessToken);

    //sample code
    var_dump($qiita->get->users());
    $arr = array();
    var_dump($qiita->put->userFollowing("kure", json_encode($arr)));
    var_dump($qiita->get->tagsItem("api"));
    $comment = array("body" => "testtest2");
    var_dump($qiita->post->comment("xxxxx", json_encode($comment)));
}catch(Exception $e){
    var_dump($e->getMessage());
}
kure
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
Comments
No comments
Sign up for free and join this conversation.
If you already have a Qiita account
Why do not you register as a user and use Qiita more conveniently?
You need to log in to use this function. Qiita can be used more conveniently after logging in.
You seem to be reading articles frequently this month. Qiita can be used more conveniently after logging in.
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
ユーザーは見つかりませんでした