commit 6224c67a391d89c79bcec4bb92688991f7c851ae Author: khuxkm Date: Fri Jul 6 23:48:24 2018 -0400 Initial commit diff --git a/README.md b/README.md new file mode 100644 index 0000000..8ec5b78 --- /dev/null +++ b/README.md @@ -0,0 +1,3 @@ +# BBJ.PHP # + +A PHP library for interacting with BBJ, as well as a client built on top of it. diff --git a/bbj.php b/bbj.php new file mode 100644 index 0000000..b34c0a7 --- /dev/null +++ b/bbj.php @@ -0,0 +1,20 @@ +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)); + } + } +?> diff --git a/test.php b/test.php new file mode 100644 index 0000000..9ba8cca --- /dev/null +++ b/test.php @@ -0,0 +1,13 @@ +thread_load("6a7232ee753e11e8a0d400163c2857c7"); + $threadd = $data["data"]; + $umap = $data["usermap"]; + $authorid = $threadd["author"]; + $authoru = $umap[$authorid]; + echo $authoru["user_name"].PHP_EOL; +?>