PHP code example of dcard / sdk

1. Go to this page and download the library: Download dcard/sdk library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

dcard / sdk example snippets



//dowloading the composer.phar firstly
curl -sS https://getcomposer.org/installer | php

//using composer.phar to install the dcard-sdk
php composer.phar 


	
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();

 composer.phar install 
 phpunit.phar src/dcard/sdk/DcardTest.php --coverage-html report/