11<?php
22/**
3- * Wrapper API Graphcomment v2.0.
3+ * Wrapper API Graphcomment v2.2
44 * @author ddtraceweb <[email protected] > 55 * @copyright 2018 Graphcomment
66 * Date: 12/11/2018
1010namespace Graphcomment ;
1111
1212use GuzzleHttp \Client ;
13+ use GuzzleHttp \Exception \GuzzleException ;
1314
1415/**
1516 * Class Sdk
@@ -93,6 +94,7 @@ public function setDir($dir)
9394 * @param string $picture (full url only example : https://graphcomment.com/image.jpg)
9495 *
9596 * @return object json response gc_id to store in your database and do_sync which define date of synchronisation
97+ * @throws GuzzleException
9698 */
9799 public function registerUser ($ username , $ email , $ language = "en " , $ picture = '' )
98100 {
@@ -119,6 +121,7 @@ public function registerUser($username, $email, $language = "en", $picture = '')
119121 * @param string $gc_id
120122 *
121123 * @return object json JWT response
124+ * @throws GuzzleException
122125 */
123126 public function loginUser ($ gc_id )
124127 {
@@ -139,6 +142,7 @@ public function loginUser($gc_id)
139142 *
140143 * @param $gc_id
141144 * @return object JSON with do_sync date, if changed, you must synchronise the informations.
145+ * @throws GuzzleException
142146 */
143147 public function getUser ($ gc_id )
144148 {
@@ -171,6 +175,7 @@ public function getUser($gc_id)
171175 * gc_id : data.gc_id,
172176 * res :'nothing updated'
173177 * }
178+ * @throws GuzzleException
174179 */
175180 public function updateUser ($ gc_id , $ username , $ email , $ language , $ picture )
176181 {
@@ -196,6 +201,7 @@ public function updateUser($gc_id, $username, $email, $language, $picture)
196201 * @param string $gc_id
197202 *
198203 * @return string ok
204+ * @throws GuzzleException
199205 */
200206 public function deleteUser ($ gc_id )
201207 {
@@ -207,13 +213,13 @@ public function deleteUser($gc_id)
207213 }
208214
209215
210-
211216 /**
212217 * countComments() return the number thread's comment
213218 *
214219 * @param $url (full url only) required
215220 * @param string $uid (unique id of the thread) optionnal
216221 * @return object json {count: numberOfComments }
222+ * @throws GuzzleException
217223 */
218224 public function countComments ($ url , $ uid ='' ) {
219225 $ client = new Client ();
@@ -228,10 +234,25 @@ public function countComments($url, $uid='') {
228234 return $ res ->getBody ();
229235 }
230236
237+
238+ public function getThreadJsonLdFormat ($ url , $ uid ='' ) {
239+ $ client = new Client ();
240+
241+ $ data = array (
242+ "url " => $ url ,
243+ "uid " => $ uid
244+ );
245+
246+ $ res = $ client ->request ('GET ' , $ this ->getDir () . '/pub/sso/thread-jsonld/pubkey/ ' . $ this ->getGcPublic (). '/key/ ' . $ this ->generateSsoData ($ data ), ['http_errors ' => false , 'timeout ' => 5 ]);
247+
248+ return $ res ->getBody ();
249+ }
250+
231251 /**
232252 * exportComments() return the comments to import in your system, group by 20 comments
233253 *
234254 * @return array of object json [{commentObject}]
255+ * @throws GuzzleException
235256 */
236257 public function exportComments () {
237258 $ client = new Client ();
@@ -247,6 +268,7 @@ public function exportComments() {
247268 * @param array $commentIds
248269 *
249270 * @return array of object json [{commentObject}]
271+ * @throws GuzzleException
250272 */
251273 public function exportConfirmComments (Array $ commentIds ) {
252274 $ client = new Client ();
0 commit comments