klangoo/magnetapiclient.php

Magnet API Client for PHP

1.0.0 2018-08-29 13:50 UTC

This package is not auto-updated.

Last update: 2025-05-15 22:42:11 UTC


README

This library allows you to easily use the Magnet API via PHP.

Table of Contents

About

Klangoo NLP API is a natural language processing (NLP) service that uses the rule-based paradigm and machine learning to recognize the aboutness of text. The service recognizes the category of the text, extracts key disambiguated topics, places, people, brands, events, and 41 other types of names; analyzes text using tokenization, parts of speech, parsing, word sense disambiguation, named entity recognition; and automatically finds the relatedness score between documents.

Read More.

Signup for a free trail

Installation

Prerequisites

  • This library is compatible with PHP version 5.3 and later.
  • An API Key Provided by Klangoo
  • An API Secret Provided by Klangoo

Install

With composer (Recommended)

Install the package via Composer:

composer require klangoo/magnetapiclient.php

Without composer

If you don't use Composer, you can download the package and include it in your code.

require_once 'MagnetApiClient.PHP-master/klangooclient.php';

Usage

This quick start tutorial will show you how to process a text.

Initialize the client

To begin, you will need to initialize the client. In order to do this you will need your API Key CALK and Secret Key. You can find both on your Klangoo account.

// composer autoload
require __DIR__ . '/vendor/autoload.php';

// if you are not using composer
// require_once 'path/to/klangooclient.php';

use KlangooClient\MagnetAPIClient;

$ENDPOINT = "https://nlp.klangoo.com/Service.svc";
$CALK = "enter your calk here";
$SECRET_KEY = "enter your secret key here";

$client = new MagnetAPIClient($ENDPOINT, $CALK, $SECRET_KEY);

$request = array("text" => "Real Madrid transfer news",
                 "lang" => "en",
                 "format" => "json");

$json = $client->CallWebMethod("ProcessDocument", $request, "POST");

Known Issues/Fixes

Curl SSL certificate problem

Error:

Curl error: SSL certificate problem: unable to get local issuer certificate

Solution:

  1. Download certificate bundle cacert.pem
  2. Add/Update the following lines in php.ini:
    curl.cainfo="<cacert_location>/cacert.pem"
    openssl.cafile="<cacert_location>/cacert.pem"