Sentiment Analysis In PHP

Sentiment Analysis in PHP

Hey Guys, As you guys know every website that deals with user reviews and feedback like Amazon, Flipkart, and many others uses sentiment analysis to detect user sentiment from the review they have posted or the feedback they have given, so they can easily detect if the user has posted Positive, Negative or Neutral review.

Demo Subcribe on Youtube

Watch the video tutorial

So this is a very easy functionality we can add in any website to read sentiment from the text using PHP.

So let’s get started,

Most of you guys already know that I have created a website Called Paysify which provides bulk SMS to Indian users

and now I have added one more product i.e Text Sentiment Analysis with API Support and it’s FREE to use Worldwide.

So now let’s get our hand dirty with API Integration.

First of all, you need to create an account on Paysify. And First time you login, you need to fill some basic details like address, state, city, etc.

So just fill those and Proceed, So now open the API Page from the link given in the sidebar, and generate an API key, and Copy it.

I have created a basic function which you can find on the documentation page


On 4th Line Replace YOUR_API_KEY with your API key, you have generated.

and now you easily call the detect_sentiment(); function which requires only one parameter i.e the text which you have to detect.

The success response will be like –

It returns 3 StateĀ Positive/Neutral/NegativeĀ with scores of all the states and one compound score which is an average of all the state.

and the error response will be like –

So I hope you can integrate this function easily in your website and make the most out of it.

Thank you guy’s for reading.

Peace Out