{"id":23176106,"url":"https://github.com/nexmo-community/sms-ibm-sentiment-php","last_synced_at":"2025-09-05T06:41:41.438Z","repository":{"id":38169005,"uuid":"210461731","full_name":"nexmo-community/sms-ibm-sentiment-php","owner":"nexmo-community","description":"PHP example using IBM Watson Tone Analysis to analyze SMS messages and determine the sentiment of the text.","archived":false,"fork":false,"pushed_at":"2025-04-29T13:26:40.000Z","size":49,"stargazers_count":0,"open_issues_count":6,"forks_count":1,"subscribers_count":9,"default_branch":"main","last_synced_at":"2025-04-29T14:41:11.201Z","etag":null,"topics":["extend","nexmo","php","sentiment-analysis","sms","sms-message","watson-tone-analyzer"],"latest_commit_sha":null,"homepage":"https://developer.nexmo.com/extend/ibm-watson-speech-to-text","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/nexmo-community.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-09-23T22:12:28.000Z","updated_at":"2023-09-13T19:46:41.000Z","dependencies_parsed_at":"2025-02-11T00:00:42.476Z","dependency_job_id":null,"html_url":"https://github.com/nexmo-community/sms-ibm-sentiment-php","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/nexmo-community/sms-ibm-sentiment-php","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexmo-community%2Fsms-ibm-sentiment-php","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexmo-community%2Fsms-ibm-sentiment-php/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexmo-community%2Fsms-ibm-sentiment-php/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexmo-community%2Fsms-ibm-sentiment-php/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/nexmo-community","download_url":"https://codeload.github.com/nexmo-community/sms-ibm-sentiment-php/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/nexmo-community%2Fsms-ibm-sentiment-php/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273723207,"owners_count":25156303,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-05T02:00:09.113Z","response_time":402,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["extend","nexmo","php","sentiment-analysis","sms","sms-message","watson-tone-analyzer"],"created_at":"2024-12-18T06:14:11.714Z","updated_at":"2025-09-05T06:41:41.399Z","avatar_url":"https://github.com/nexmo-community.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# SMS Sentiment Analysis with IBM Tone Analyzer using PHP\n\n[![Deploy](https://www.herokucdn.com/deploy/button.svg)](https://nexmo.dev/sms-ibm-sentiment-php-heroku)\n\nPHP script for callback to return sentiment analysis from the IBM Tone Analyzer to grade the contents of an SMS message sent through a Nexmo number. This example script uses Composer to include slim/slim, slim/psr7, guzzlehttp/guzzle, and vlucas/phpdotenv.\n\n## IBM Tone Analyzer Service\n\nReference: [https://www.ibm.com/watson/services/tone-analyzer/](https://www.ibm.com/watson/services/tone-analyzer/)\nAPI Docs: [https://cloud.ibm.com/apidocs/tone-analyzer](https://cloud.ibm.com/apidocs/tone-analyzer)\nGitHub: [https://github.com/watson-developer-cloud/node-sdk#tone-analyzer](https://github.com/watson-developer-cloud/node-sdk#tone-analyzer)\n\nRegister for the [IBM Tone Analyzer service](https://console.bluemix.net/catalog/services/tone-analyzer). Once created, make a note of the API Key and URL for use later. These can be found in the Manage page of the IBM Cloud dashboard after login.\n\n---\n\n**Note for IBM Cloud deploy**: Once the app has deployed, go to the app dashboard and update the environment variables with these credentials under \"Runtime \u003e Environment Variables\"\n\n---\n\n## Running the App\n\nThis sample app uses a `.env` file to provide the API key and URL to the IBM Tone Analyzer API.\n\nCopy the provided `.env.example` file to a new file called `.env`:\n\n```\ncp .env.example \u003e .env\n```\n\nThen update the values with those from the IBM Tone Analyzer service Manage page, and then save.\n\n```\nTONE_ANALYZER_IAM_APIKEY=\nTONE_ANALYZER_URL=\n```\n\nAlso, expose the application to the internet using tools like [ngrok](https://ngrok.com/). To see how, [check out this guide](https://www.nexmo.com/blog/2017/07/04/local-development-nexmo-ngrok-tunnel-dr/).\n\n### Use Composer to install dependencies\n\nBoth methods of serving the app, shown below, do require the use of Composer to install dependencies and set up the autoloader.\n\nAssuming a Composer global installation. [https://getcomposer.org/doc/00-intro.md#globally](https://getcomposer.org/doc/00-intro.md#globally)\n\n```\ncomposer install\n```\n\n#### Docker Method\n\nTo run the app using Docker-Compose, run the following command in a terminal:\n\n```\ndocker-compose up\n```\n\nThis will create a new container and serve it from http://localhost:8080.\n\n#### PHP Built-in Webserver Method\n\nAlternatively, it can be ran using the PHP built-in web server for testing purposes. This method requires us to run Composer for installation of dependencies.\n\n##### Launching the PHP built-in webserver\n\nTo serve the app run the following command in a terminal:\n\n```\nphp -S localhost:8080\n```\n\n## Linking the app to Nexmo\n\nFor this example app a Nexmo number and SMS webhook setup is needed.\n\nThis can be achieved with the Nexmo CLI. Install the CLI by following [these instructions](https://github.com/Nexmo/nexmo-cli#installation).\n\n### Rent a New Virtual Number\n\nRenting a number will need to be in place. This can also be achieved using the CLI by running this command:\n\n```\nnexmo number:buy --country_code US\n```\n\n### Adding the SMS Webhook\n\nUpdate the number created with the URL of the hosted or local server.\n\n```\nnexmo link:sms phone_number https://my-hostname/message\n```\n\n## Try it out\n\nWith the example PHP application running in the terminal, send various SMS messages to the virtual number.  The terminal will output the response from IBM Tone Analyzer.\n\n![Watson analysis](https://github.com/nexmo-community/sms-sentiment-watson/blob/master/sms.png?raw=true)\n\n![Watson analysis](https://github.com/nexmo-community/sms-sentiment-watson/blob/master/emotion-analysis.png?raw=true)\n\n## Extend\nThis app prints out to the console. For integration with an application, extend the `analyzeTone` function to suit your needs.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexmo-community%2Fsms-ibm-sentiment-php","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fnexmo-community%2Fsms-ibm-sentiment-php","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fnexmo-community%2Fsms-ibm-sentiment-php/lists"}