Skip to content
This repository has been archived by the owner on May 28, 2023. It is now read-only.

Content Items (1.1)

Percy Mamedy edited this page Jun 4, 2017 · 3 revisions

Content Items

Structure

The Package accepts as its input an array of contentItems. Each Content Item is essentially an array with content, userid, sourceid and so on.

Below is a list of fields that a contentItem supports:

id [string] | (Optional)

A unique identifier for this content item.

content [string] | (Required)

A maximum of 20 MB of content to be analyzed.

userid [string] | (Optional)

A unique identifier for the author of this content.

sourceid [string] | (Optional)

An identifier for the source of this content; for example, blog123 or twitter.

created [integer] | (Optional)

When was the content created, UNIX Timestamp.

updated [integer] | (Optional)

When was the content updated, UNIX Timestamp.

contenttype [string] | (Optional)

The MIME type of the content: Defaults to text/plain

  • text/plain
  • text/html

language [string] | (Optional)

The language of the content as a two-letter ISO 639-1 identifier: Defaults to en

  • ar (Arabic)
  • en (English, the default)
  • es (Spanish)
  • ja (Japanese)

Regional variants are treated as their parent language; for example, en-US is interpreted as en.

parentid [string] | (Optional)

The unique ID of the parent content item for this item. Used to identify hierarchical relationships between posts/replies, messages/replies, and so on.

reply [boolean] | (Optional)

Indicates whether this content item is a reply to another content item.

forward [boolean] | (Optional)

Indicates whether this content item is a forwarded/copied version of another content item.

Example

Here is an example of a contentItem peice:

$singleContentItem = [
     "content"      => "Wow, I liked @TheRock before , now I really SEE how special he is. The daughter story was IT for me. So great! #MasterClass",
     "contenttype"  => "text/plain",
     "created"      => 1447639154000,
     "id"           => "666073008692314113",
     "language"     => "en",
     "sourceid"     => "Twitter API",
     "userid"       => "@Oprah"
];

Input

To add a single contentItem to the service use the addSingleContentItem() method:

// Create the PI service.
$personalityInsights = $this->app->make('PersonalityInsights');

// Add single contentItem.
$personalityInsights->addSingleContentItem($singleContentItem);

To add an array of contentItem (which is what you would do in most cases), use the addContentItems() methods, which accepts an array of contentItems:

// Create the PI service.
$personalityInsights = $this->app->make('PersonalityInsights');

// Add contentItems.
$personalityInsights->addContentItems($contentItems);