2017 © Pedro Peláez
 

library sdk-api-php

PHP wrapper for the Graphcomment API

image

graphcomment/sdk-api-php

PHP wrapper for the Graphcomment API

  • Tuesday, November 21, 2017
  • by ddtraceweb
  • Repository
  • 2 Watchers
  • 3 Stars
  • 15 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 8 Versions
  • 0 % Grown

The README.md

Scrutinizer Code Quality Build Status, (*1)

Graphcomment SDK API PHP version 2.3.2

install with composer :, (*2)

composer require graphcomment/sdk-api-php, (*3)

  • The Wrapper use the last version of Guzzle., (*4)

  • To use the PHP Wrapper you must create an account on Graphcomment.com and subscribe a paid plan., (*5)

With this wrapper you will be able to :, (*6)

  • Register automatically a new User on GraphComment whenever he subscribe on your website.
  • Connect a user to GraphComment when he logs in to your website.
  • Get the user information saved in graphcomment.
  • Update the user information from your system to graphcomment.
  • Get the count of comments active on a thread.

Example of implementation :, (*7)

$client = new Sdk(GC_PUBLIC_KEY, GC_SECRET_KEY);, (*8)

after theses lines, you call the functions., (*9)

  • register a User

$client->registerUser('username', 'email', 'fr', 'https://graphcomment.com/image.jpg');, (*10)

This function return a json file containing its "gc_id" that must be save in your database to authenticate a user that is logging in and do_sync date of synchronisation to save too., (*11)

  • login a User, this function return the token JWT as JSON that you must save in localStorage to authenticate Graphcomment.

$client->loginUser('gc_id');, (*12)

to save in localStorage the gc_token, call this url in an iframe with 0px width, 0px width of user to authenticate him => https://graphcomment.com/fr/auth.html?gc_token=[TOKEN-without-JWT-only-token], (*13)

to destroy session localStorage, call this url in an iframe with 0px width, 0px width of user => https://graphcomment.com/fr/destroy.html, (*14)

Example :, (*15)

Connexion :, (*16)

<iframe src="https://graphcomment.com/fr/auth.html?gc_token=eyJhbGciOiJIUzI1NiIsInR5cCI6kpXVCJ9.eyJfaWQiOiI1OGY5ZjQ5OTk3NzkwOTBkODYyMDgwOTIiLCJ1c2VybmFtZSI6ImRhdmlkIGRqaWFuIiwiZW1haWwiOiJzaXJiYWxkdXJAZ21haWwuY29tIiwiZmFjZWJvb2tfaWQiOiIxMDE1NDE3Mjk2NzQ1MTQ5MSIsImdvb2dsZV9pZCI6IjExNjEwMTAxNzgxODA3MjI5MDk0OCIsInJvbGUiOJ1c2VyIiwicGljdHVyZSI6Ii9pbWFnZXMvYXZhdGFyXzMucG5nIiwibGFuZ3VhZ2UiOiJmciIsImZyb21fd2Vic2l0ZSI6IjU4MWQyMTlmOGRmY2EwMzlhY2MMGZiZiIsInZhbGlkYXRpb24iOnt9LCJpYXQiOjE0OTk2ODYxMjIsImV4cCI6MTUwMjI3ODEyMn0.YyiANmL4-wzu1XGak1SbBmywZOWLHwjYsXtBW-Ikqx4 " frameborder="0" style="width:0px;height:0px;"></iframe>, (*17)

Disconnection :, (*18)

<iframe src="https://graphcomment.com/fr/destroy.html" frameborder="0" style="width:0px;height:0px;"></iframe>, (*19)

  • Get last informations from a user

$client->getUser('gc_id');, (*20)

get user's informations, return a JSON., (*21)

{
    gc_id: 'gc_id',
    username: 'username',
    email: 'email@email.com',
    language : 'en',
    picture : 'https://graphcomment.com/image.jpg',
    do_sync : date of synchronisation
}
  • Update a User on Graphcomment

$client->updateUser('gc_id', 'username', 'email', 'fr', 'https://graphcomment.com/image.jpg');, (*22)

return do_sync date and gc_id with state 'updated', (*23)

  • Count Comments of a thread

$client->countCommentscountComments('https://graphcomment.com/thread.html', 'content123');, (*24)

  • Export Comments to synchronise with your databases

This query is limited by 100 comments for each query., (*25)

$client->exportComments();, (*26)

list 100 comments in json array :, (*27)

{
    comments : [
     {
         "cached_author": {
           "username": "gc",
           "email": "grdnlndn@gmail.com"
         },
         "guest": false,
         "status": "approved",
         "spam": false,
         "_id": "5cb0621843647e1332eba194",
         "content": "test from GC 7",
         "thread": {
           "_id": "5c790ace3f227b1ac45a29b7",
           "url": "http://localhost:8080/?p=5",
           "page_title": "Article with GC",
           "guid": "http://localhost:8080/?p=5",
           "uid": "5"
         },
         "author": {
           "profiles": [
             {
               "language": "fr",
               "_id": "5c790acd3f227b1ac45a29b6",
               "username": "gc",
               "email": "grdnlndn@gmail.com",
               "uid": "1"
             }
           ],
           "_id": "59c0cd87740e0704dba1cf6b"
         },
         "ip": "176.164.57.27",
         "edited_at": "2019-04-12T10:02:00.376Z",
         "created_at": "2019-04-12T10:02:00.343Z"
       },
       {
           "cached_author": {
             "username": "gc",
             "email": "grdnlndn@gmail.com"
           },
           "guest": false,
           "status": "deleted",
           "spam": false,
           "_id": "5cb0621843647e1332eba194",
           "content": "test from GC 7",
           "thread": {
             "_id": "5c790ace3f227b1ac45a29b7",
             "url": "http://localhost:8080/?p=5",
             "page_title": "Article with GC",
             "guid": "http://localhost:8080/?p=5",
             "uid": "5"
           },
           "author": {
             "profiles": [
               {
                 "language": "fr",
                 "_id": "5c790acd3f227b1ac45a29b6",
                 "username": "gc",
                 "email": "grdnlndn@gmail.com",
                 "uid": "1"
               }
             ],
             "_id": "59c0cd87740e0704dba1cf6b"
           },
           "ip": "176.164.57.27",
           "edited_at": "2019-04-12T10:02:00.376Z",
           "created_at": "2019-04-12T10:02:00.343Z"
         }

    ]
}
  • Valid Import Comments in your system, send us confirmation

$client->exportConfirmComments([comment_id1, comment_id2, comment_id3...]);, (*28)

This query return a JSON Array of object :, (*29)

{
    [
     {_id : comment_id1, result: 'ok'},
     {_id : comment_id2, result: 'ko', message:'comment id not found'},
     {_id : comment_id3, result: 'ok'},

    ]
}
  • Get JSON-LD Format From Url and Uid(optionnal) content for SEO

$client->getThreadJsonLdFormat('https://graphcomment.com/thread.html', 'content123');, (*30)

message is present only if an error exist for a comment upgrade in our database., (*31)

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. you have to do an update or insert function depending on the case., (*32)

So you can make a job to get all minutes and import the graphcomment comments in your database., (*33)

The Versions

21/11 2017

dev-master

9999999-dev https://github.com/graphcomment/sdk-php-api

PHP wrapper for the Graphcomment API

  Sources   Download

MIT

The Requires

 

api php comment graphcomment

21/11 2017

1.0.6

1.0.6.0 https://github.com/graphcomment/sdk-php-api

PHP wrapper for the Graphcomment API

  Sources   Download

MIT

The Requires

 

api php comment graphcomment

25/10 2017

1.0.5

1.0.5.0 https://github.com/graphcomment/sdk-php-api

PHP wrapper for the Graphcomment API

  Sources   Download

MIT

The Requires

 

api php comment graphcomment

25/10 2017

1.0.4

1.0.4.0 https://github.com/graphcomment/sdk-php-api

PHP wrapper for the Graphcomment API

  Sources   Download

MIT

The Requires

 

api php comment graphcomment

25/10 2017

1.0.3

1.0.3.0 https://github.com/graphcomment/sdk-php-api

PHP wrapper for the Graphcomment API

  Sources   Download

MIT

The Requires

 

api php comment graphcomment

21/07 2017

v1.0.2

1.0.2.0 https://github.com/graphcomment/sdk-php-api

PHP wrapper for the Graphcomment API

  Sources   Download

MIT

The Requires

 

api php comment graphcomment

11/05 2017

v1.0.1

1.0.1.0 https://github.com/graphcomment/sdk-php-api

PHP wrapper for the Graphcomment API

  Sources   Download

MIT

The Requires

 

api php comment graphcomment

24/04 2017

v1.0

1.0.0.0 https://github.com/graphcomment/sdk-php-api

PHP wrapper for the Graphcomment API

  Sources   Download

MIT

The Requires

 

api php comment graphcomment