2017 © Pedro Peláez
 

sdk sdk

It's unofficial Dcard sdk to access Dcard HTTP api

image

dcard/sdk

It's unofficial Dcard sdk to access Dcard HTTP api

  • Tuesday, August 23, 2016
  • by peter279k
  • Repository
  • 2 Watchers
  • 4 Stars
  • 16 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 14 Versions
  • 0 % Grown

The README.md

dcard-sdk

Help you to access easily the internal and official HTTP Dcard api., (*1)

Latest Stable Version Total Downloads Latest Unstable Version License, (*2)

Dcard HTTP API implementation

We implement the following API methods, (*3)

The base url is https://www.dcard.tw/, (*4)

Request url description HTTP method response format the method
/_api/me get account information GET json getMe
/_api/forums get forum lists GET json getForums
/_api/dcard get today "Dcard" GET json getDcard
/_api/notifications get your notifications GET json getNotification
/_api/posts/{post-id} get specified post contents GET json getPostContents
/_api/forums/posts?popular={true/false}&before={post-id} get specified forums's post lists GET json getPostLists
/_api/sessions To login the Dcard Account POST json dcardLogin
/_api/dcard/accept Invite friends POST json sendAccept
/logout logout from the Dcard GET json dcardLogout

If you have to call other api methods, please open issue and let me know your requirement, (*5)

Usage


//dowloading the composer.phar firstly curl -sS https://getcomposer.org/installer | php //using composer.phar to install the dcard-sdk php composer.phar require dcard/sdk

Sample code

require "vendor/autoload.php";

use Dcard\sdk\DcardSdk;

$dcard = new DcardSdk("your account", "your password");

//login

$response = $dcard -> dcardLogin();

//get me

$response = $dcard -> getMe();

//get forums

$response = $dcard -> getForums();

//get "dcard"

$response = $dcard -> getDcard();

//get your account notifications

$response = $dcard -> getNotification();

//get specified post

$response = $dcard -> getPostContents("your-post-id");

//invite friends

$response = $dcard -> sendAccept("your-first-message");

//get specified forum's post lists
/*
    @param(type: string) $ForumName: the forum English name.
    @param(type: string) $IsPopular: the post whether is popular in forum or not and the value is true or false. 
    @param(type: boolean) $IsBefore: the post whether is the first page or specified page.
    @param(type: string) $PostId: the $IsBefore set true and the specified post id will get specified page.
    the $IsBefore set false and the specified post id will get specified page.
*/

$response = $dcard -> getPostLists($ForumName, $IsPopular, $IsBefore, $PostId);

//Dcard logout

$response = $dcard -> dcardLogout();

Unit Testing

I use PHPUnit to test the package., (*6)

Here is the steps to test the package., (*7)

Step 1

clone the project in master branch., (*8)

Step 2

manually download the PHPUnit.phar., (*9)

Step 3

download the composer.phar., (*10)

Step 4

do php composer.phar install in project root folder., (*11)

Step 5

create the folder which name is report in project root folder., (*12)

Step 6

In DcardTest.php, replace the account and password on line 11 and 28., (*13)

Step 7

run testing: php phpunit.phar src/dcard/sdk/DcardTest.php --coverage-html report/, (*14)

Here is the testing result., (*15)

Alt text, (*16)

Change log

2016/08/13

  1. add invite friend 新增寄送邀請功能

Related project

Dcard-API is developed by Node.js: Dcard-API, (*17)

The Versions

23/08 2016

dev-master

9999999-dev

It's unofficial Dcard sdk to access Dcard HTTP api

  Sources   Download

MIT

The Requires

 

by Avatar peter279k

12/08 2016

v1.1.2

1.1.2.0

It's unofficial Dcard sdk to access Dcard HTTP api

  Sources   Download

MIT

The Requires

 

by Avatar peter279k

12/08 2016

v1.1.1

1.1.1.0

It's unofficial Dcard sdk to access Dcard HTTP api

  Sources   Download

MIT

The Requires

 

by Avatar peter279k

11/08 2016

v1.1.0

1.1.0.0

It's unofficial Dcard sdk to access Dcard HTTP api

  Sources   Download

MIT

The Requires

 

by Avatar peter279k