Download the PHP package info-com/econtext-sdk-php without Composer
On this page you can find all versions of the php package info-com/econtext-sdk-php. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download info-com/econtext-sdk-php
More information about info-com/econtext-sdk-php
Files in info-com/econtext-sdk-php
Package econtext-sdk-php
Short Description A PHP client to interact with the eContext API
License LGPL-3.0+
Homepage http://www.econtext.com
Informations about the package econtext-sdk-php
A simple PHP client to expose the eContext API.
Installation
We recommending using Composer to include the eContext library in your project. In the composer.json file for your project you can simply include econtext-sdk-php and Composer will handle downloading and including the most recent version for you.
Basic Usage
eContext\Client
The basic client object that wraps in the GuzzleHttp objects. It should be passed to each of the calls that are passed in to the API.
Parameters
- $username An API username
- $password An API password
- $baseuri The base URI for the API. By default, this is set to http://api.econtext.com
- $statusCallback A callback which is called after every API interaction.
The statusCallback can be used to interact during a run. The callback function must receive two parameters. The first is an index number corresponding to the sequence id for that call (e.g. $data[4]). The second is a GuzzleHttp Response object for the call (this is true if the API call is successful or fails).
eContext\Classify\Type\Social
A Social Classification object which interacts with the classify/social endpoint. The data object for the Social object
should be a list of social content phrases (e.g. ["this is my first tweet that I want to classify", "this is my second tweet that I want to classify", ...]) and may contain as many elements as you would like. This list will be broken up
and sent to the API in separate calls. These calls may be parallelized by setting the concurrency parameter in the
$social->classify() call. For example, if you have 10,000 elements to be classified and set concurrency to 5, you
should be able to run 5 sets of calls at the same time, each sending over 1000 elements at once, so 5,000 concurrently.
When the calls are completed, you can retrieve them in the order that they were submitted using the object returned from the classify() call.
You may pass in extra parameters to the classification calls as well. For example, in order to specify that only the
eContext Rule-Based Classifications should be used, you can call $classify->setParameter('classification_type', 1);
eContext\Classify\Result
The base result object for eContext Classification objects. Each time a result is yielded in the yieldResults() call, a
Result object is created and populated with several items. Each of the different classification types extends this
object, but the base object is still created and populated with, at least, categories, translate, overlay and
inner parameters. Individual categories may be retrieved using $result->getCategory($id) calls and will return
an associated category array. The inner parameter contains the entire inner contents of the API call, and can be used
for manual exploration of the result object.
eContext\Classify\Results\Social
The result object for Social classification will yieldResults across all of the input data. If you input 10,000 tweets
in the data for the $classify object, yieldResults should yield 10,000 result arrays. Each of these arrays will
contain an associated array with the inner contents of the API result. When a new page is loaded, for example when you
go from post 1000 to post 1001, the object's categories array will change as well to load in the new categories for that
page. This means that categories that existed on the first page may no longer be available on the second page.
In addition to the categories, inner, translate, and overlay parameters stored in the generic Result object, the
Social Result object will also contain a results object that corresponds to the items yielded in the yieldResults
call.
eContext\Classify\Results\Html and eContext\Classify\Results\Url
The results objcet for both HTML and URL classification objects. Each data object passed in to the either the URL or HTML classification objects may contain multiple elements. For example, you may populate the $html_classify object with HTML content from several different pages at once, or several urls at once.
For example:
The output from the above calls should look like this:
Note how the $results->getCategories() object changed with each advance through the iterator, and returns the categories associated with the current page (the current url_result).
Each $url_result object contains three items.
- 'title' -- corresponds to the title element in the HTML/URL page that was retrieved
- 'scored_categories' -- a list of scored_category objects, each of which contains a
category_idandscore. - 'scored_keywords' -- a list of keywords that were of value in the page