Skip to content

Commit cc4e96b

Browse files
David DjianDavid Djian
authored andcommitted
add thread json-ld format
1 parent ac443d0 commit cc4e96b

File tree

2 files changed

+29
-3
lines changed

2 files changed

+29
-3
lines changed

README.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/graphcomment/sdk-api-php/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/graphcomment/sdk-api-php/?branch=master)
22
[![Build Status](https://scrutinizer-ci.com/g/graphcomment/sdk-api-php/badges/build.png?b=master)](https://scrutinizer-ci.com/g/graphcomment/sdk-api-php/build-status/master)
33

4-
#Graphcomment SDK API PHP version 2.0
4+
#Graphcomment SDK API PHP version 2.2
55

66
install with composer :
77

@@ -175,6 +175,10 @@ This query return a JSON Array of object :
175175
}
176176
```
177177

178+
- Get JSON-LD Format From Url and Uid(optionnal) content for SEO
179+
180+
`$client->getThreadJsonLdFormat('https://graphcomment.com/thread.html', 'content123');`
181+
178182
message is present only if an error exist for a comment upgrade in our database.
179183

180184
Comment export returns the comment if it has changed status, or if it has been edited by the user in case of account deletion or normal editing.

src/Graphcomment.php

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
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
@@ -10,6 +10,7 @@
1010
namespace Graphcomment;
1111

1212
use 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

Comments
 (0)