mirror of https://github.com/bbj-dev/bbjphp.git
Initial commit
This commit is contained in:
commit
6224c67a39
|
@ -0,0 +1,3 @@
|
|||
# BBJ.PHP #
|
||||
|
||||
A PHP library for interacting with BBJ, as well as a client built on top of it.
|
|
@ -0,0 +1,20 @@
|
|||
<?php
|
||||
// This file is part of BBJ.PHP by khuxkm fbexl
|
||||
// Licensed under MIT.
|
||||
// The actual BBJ interaction class.
|
||||
class BBJ {
|
||||
public function __construct($host,$port) {
|
||||
$this->base_url = "http://{$host}:${port}/api/";
|
||||
}
|
||||
public function request($api_method,$params) {
|
||||
$ctx = stream_context_create(array("http"=>array("method"=>"POST","header"=>"Content-Type: text/json","content"=>json_encode($params))));
|
||||
return json_decode(file_get_contents($this->base_url.$api_method,FALSE,$ctx),true);
|
||||
}
|
||||
public function thread_index($include_op=FALSE) {
|
||||
return $this->request("thread_index",array("include_op"=>$include_op));
|
||||
}
|
||||
public function thread_load($thread_id,$format=null,$op_only=FALSE) {
|
||||
return $this->request("thread_load",array("thread_id"=>$thread_id,"format"=>$format,"op_only"=>$op_only));
|
||||
}
|
||||
}
|
||||
?>
|
|
@ -0,0 +1,13 @@
|
|||
<?php
|
||||
// This file is part of BBJ.PHP by khuxkm fbexl
|
||||
// Licensed under MIT.
|
||||
// A test. Specific to ~team BBJ
|
||||
include 'bbj.php';
|
||||
$bbj = new BBJ("127.0.0.1",7099);
|
||||
$data = $bbj->thread_load("6a7232ee753e11e8a0d400163c2857c7");
|
||||
$threadd = $data["data"];
|
||||
$umap = $data["usermap"];
|
||||
$authorid = $threadd["author"];
|
||||
$authoru = $umap[$authorid];
|
||||
echo $authoru["user_name"].PHP_EOL;
|
||||
?>
|
Loading…
Reference in New Issue