Open Graph (og) API

Open Graph (og) API / service for loading OG meta data documentation

 

Basic information

A service that reads Open Graph meta data from a specific site.

 

Token and service authentication

You need to be logged in user before you can use the service.

We simplified the login / registration in the easiest way possible. Only you need to sign in with your Google / Gmail account to continue. After logging into the token field (below) you will be able to use your personal token on PHP.mk services.

Personal Token

Login to show token!

 

Using the Service v1.0

Version ({version}): v1.0

Link to page ({url}): ?url= e.g. "https://tocka.com.mk/vesti/297367/specijalno-izdanie-na-alfa-romeo-4c-spider-italia"

service end-point

HTTP/GET

https://api.php.mk/og/{version}?token={token}&url={url}

Example HTTP/GET request

https://api.php.mk/og/v1.0?token=&url=https://tocka.com.mk/vesti/297367/specijalno-izdanie-na-alfa-romeo-4c-spider-italia

Example PHP

$url='https://api.php.mk/og/v1.0?token=&url=https://tocka.com.mk/vesti/297367/specijalno-izdanie-na-alfa-romeo-4c-spider-italia';
$jsonResponse=file_get_contents($url);
$response= json_decode($jsonResponse,true);
            
echo '<pre>';
print_r($response['data']);
exit();

Example cUrl

curl -X GET  'https://api.php.mk/og/v1.0?token=&url=https://tocka.com.mk/vesti/297367/specijalno-izdanie-na-alfa-romeo-4c-spider-italia';

Example Javascript

var xhr = new XMLHttpRequest();
xhr.addEventListener("readystatechange", function () {
  if (this.readyState === 4) {
    var response_data=JSON.parse(this.responseText).data;
    console.log(response_data);
  }
});
xhr.open("GET", "https://api.php.mk/og/v1.0?token=&url=https://tocka.com.mk/vesti/297367/specijalno-izdanie-na-alfa-romeo-4c-spider-italia");
xhr.send();

Example jQuery / JavaScript

$.getJSON('https://api.php.mk/og/v1.0?token=&url=https://tocka.com.mk/vesti/297367/specijalno-izdanie-na-alfa-romeo-4c-spider-italia',function(r){

    console.log(r.data);

}).error(function(error){

    console.log(error.responseJSON.msg);

});

 

Service response

The answer is always in JSON format

The response from the service is the content of the meta OG data in JSON format.

Example response

{
    "error": false,
    "status_text": "OK",
    "status_code": 200,
    "data": {
        "type": "article",
        "site_name": "IT.mk",
        "title": "Приказната на Џеф Безос и основањето на Amazon ⋆ IT.mk",
        "description": "Главната улога во вестите последниве неколку месеци без сомневање ја има Џеф Безос. Овој период некако е полн со добри и лоши вести за Безос и Amazon. На",
        "image": "https://www.it.mk/wp-content/uploads/2019/02/15447515584_ba97e5589a_b.jpg",
        "url": "https://www.it.mk/prikaznata-na-dhef-bezos-i-osnovaneto-na-amazon/"
    }
}