2017 © Pedro Peláez
 

library answers-client

Answers Client for Answers Application

image

linkorb/answers-client

Answers Client for Answers Application

  • Wednesday, November 25, 2015
  • by joostfaassen
  • Repository
  • 7 Watchers
  • 0 Stars
  • 7 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 0 % Grown

The README.md

Answers Client

PHP client library for Answers application., (*1)

Installation

composer require linkorb/answers-client

Example

Client, (*2)

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

use Linkorb\AnswersClient\Client as Client;
use Linkorb\AnswersClient\Question as Question;

// get the client
$client = new Client(
    '<Host>',
    '<Username>',
    '<Password>'
);

Question, (*3)


// Create Question $question = new Question( $client ); $question->setQuestion(<Question>); $question->setDescription(<Description>); $question->setTopicId(<topic id>); try { $question->create(); } catch( Exception $e ) { echo $e->getMessage(); } $question->setQuestion(<question>); try { $question->update(); } catch( Exception $e ) { echo $e->getMessage(); } // Get Question $question = new Question( $client ); $question->get(<Question id>); $answers = $question->getAnswers(); var_dump($answers); $comments = $question->getComments(); var_dump($comments); $votes = $question->getVotes(); var_dump($votes); // Update question $question = new Question( $client ); $question->get(<Question id>); $question->setQuestion(<Question>); $question->setDescription(<Description>); try { $question->update(); } catch( Exception $e ) { echo $e->getMessage(); } // Delete question $question = new Question( $client ); $question->get(<Question Id>); try { $question->delete(); } catch( Exception $e ) { echo $e->getMessage(); } //Comment $question = new Question( $client ); $question->get(<Question id>); try { $question->comment(<Comment>); } catch( Exception $e ) { echo $e->getMessage(); } // Vote $question = new Question( $client ); $question->get(<Question id>); try { $question->vote(); } catch( Exception $e ) { echo $e->getMessage(); }

Answer, (*4)

// Create Answer 
$answer = new Answer( $client );
$answer->setQuestionId( <Question id> );
$answer->setAnswer( <Answer id> );

try {
    $answer->create(); 
} catch( Exception $e ) {
    echo $e->getMessage();
} 

// Get Answer
$answer = new Answer( $client );
$answer->get( <Answer id> );

$comments = $answer->getComments();
var_dump($comments);

$votes = $answer->getVotes();
var_dump($votes);

// Update Answer
$answer = new Answer( $client );
$answer->get( <Answer id> );

$answer->setAnswer(<Answer>);

try {
    $answer->update(); 
} catch( Exception $e ) {
    echo $e->getMessage();
} 

// Delete Answer
$answer = new Answer( $client );
$answer->get(<Answer id>);

try {
    $answer->delete(); 
} catch( Exception $e ) {
    echo $e->getMessage();
} 

// Commnent Answer
$answer = new Answer( $client );
$answer->get(<Answer Id>);

try {
    $answer->comment(<Comment>); 
} catch( Exception $e ) {
    echo $e->getMessage();
} 

// Vote Answer
$answer = new Answer( $client );
$answer->get(<Answer Id>);

try {
    $answer->vote(); 
} catch( Exception $e ) {
    echo $e->getMessage();
} 

Comment, (*5)

// Get comment
$comment = new Comment( $client );
$comment->get(<Comment Id>);

$votes = $comment->getVotes();
var_dump($votes);

// Update comment
$answer = new Answer( $client );
$answer->get(<Answer id>);

$answer->setAnswer(<Answer>);

try {
    $answer->update(); 
} catch( Exception $e ) {
    echo $e->getMessage();
} 

// Delete comment
$comment = new Comment( $client );
$comment->get(<Comment id>);

try {
    $comment->delete(); 
} catch( Exception $e ) {
    echo $e->getMessage();
} 

// Vote comment
$comment = new Comment( $client );
$comment->get(<Comment id>);

try {
    $comment->vote(); 
} catch( Exception $e ) {
    echo $e->getMessage();
} 

Vote, (*6)

// Delete comment
$vote = new Vote( $client );
$vote->get(<Vote id>);

try {
    $vote->delete(); 
} catch( Exception $e ) {
    echo $e->getMessage();
} 

Brought to you by the LinkORB Engineering team


Check out our other projects at engineering.linkorb.com., (*7)

Btw, we're hiring!, (*8)

The Versions

25/11 2015

dev-master

9999999-dev https://github.com/linkorb/answers-client

Answers Client for Answers Application

  Sources   Download

MIT

The Requires

 

The Development Requires

by LinkORB
by Kishan Thobhani

php linkorb answers client-library

25/11 2015

v1.0

1.0.0.0 https://github.com/linkorb/answers-client

Answers Client for Answers Application

  Sources   Download

MIT

The Requires

 

The Development Requires

by LinkORB
by Kishan Thobhani

php linkorb answers client-library