User manual
Back to table of contents

OpenGraph

Creating posts

To extract the OpenGraph information about URL (or to download the image by URL), make the POST request to /api/v1/open_graphs.json with the following body:

{
  "text": "http://www.scribd.com/doc/30715288/The-Open-Graph-Protocol-Design-Decisions"
}

Response

You should get an HTTP 201 response with the following body:

{
  "open_graph": {
    "id": 56,
    "user_id": 1,
    "url": "http://www.scribd.com/doc/30715288/The-Open-Graph-Protocol-Design-Decisions",
    "title": null,
    "description": null,
    "author": null,
    "status": "new",
    "diagnostics": null,
    "created_at": "2016-01-06T19:52:00.000Z",
    "updated_at": "2016-01-06T19:52:00.000Z"
  }
}

Now you will have to wait until this OpenGraph object is processed by polling every second for the GET URL from the next section.

Curl command line:

curl -n -X POST https://mokum.place/api/v1/open_graphs.json \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-API-Token: $MOKUM_API_TOKEN" \
-d '{
  "text": "http://www.scribd.com/doc/30715288/The-Open-Graph-Protocol-Design-Decisions"
}'

Getting OpenGraph object

To get the status of OpenGraph object, do HTTP GET to /api/v1/open_graphs/:id.json URL. When “status” field becomes “ok” or “failed”, you should stop polling.

Some OpenGraph objects also have accompanying images which need to be processed by Mokum. To get the status of this processing, use the /api/v1/attachments.json URL which is described in Attachments section.

Response

{
  "open_graph": {
    "id": 55,
    "user_id": 1,
    "url": "http://www.scribd.com/doc/30715288/The-Open-Graph-Protocol-Design-Decisions",
    "title": "The Open Graph Protocol Design Decisions",
    "description": "Presentation at the W3C's Linked Data Camp at WWW 2010. April 29th, 2010.",
    "author": "",
    "status": "ok",
    "diagnostics": "HTTP 200 OK GET http://www.scribd.com/doc/30715288/The-Open-Graph-Protocol-Design-Decisions (207091 bytes, 0.653 sec)\nOpenGraph data extracted successfully\nHTTP 200 OK GET https://imgv2-2-f.scribdassets.com/img/document/30715288/original/fit_to_size/192x256/2602468956/1443564270 (6644 bytes, 0.488 sec)",
    "created_at": "2016-01-06T19:48:26.000Z",
    "updated_at": "2016-01-06T19:48:27.000Z"
  }
}

Curl command line:

curl -n -X GET https://mokum.place/api/v1/open_graphs/$ID.json \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-H "X-API-Token: $MOKUM_API_TOKEN"