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

First Steps (1.0)

Percy Mamedy edited this page Mar 11, 2017 · 1 revision

Taking your first step

After having configured and having a good understanding of what inputs to feed to the package, lets take a look at how to use the library to get our first profile.

Collect Data

First collect data following the array structure given in Dealing with input

//Create data to feed for analysis
$dataToAnalyse = [
    [
        "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"
    ]
    [
        ....
    ]
];

Create service and pass in data collected

Once you have some data to analyse, resolve the service PersonalityInsights out of the IOC container using app('PersonalityInsights') or app()->make('PersonalityInsights') and pass the array of data using the addContentItems() method.

//Create the service and pass in data 
$insights = app()->make('PersonalityInsights')->addContentItems($dataToAnalyse);

Alertnatively you can use the Facade PersonalityInsights::addContentItems($dataToAnalyse);, but keep in mind that the facade will always resolve the same PersonalityInsights object from the IOC if you have multiple profile to analyse it is best to use app()->make('PersonalityInsights') to create different instance of the service object.