Open Calais Tags

Open Calais Tags is a PHP class for extracting entities and tags from text using Open Calais. Calais performs semantic analysis of the text, using natural language processing to identify concepts like people, companies and technologies discussed in the text. These are especially useful for suggesting tags for your content such as website articles or blog posts. You could even automatically tag archived content that would take days to go through manually.

You can download the class and example usage here: (updated 6/10/2015)

Calais is free for both personal and commercial use, and usage of this class requires a Calais API key. Getting an API key is an easy, automated process. Just click the “Access API” link at the site.

The Open Calais Tags class takes a document (text or HTML string) as input, and returns an array as output. The array’s keys are the entity types detected in the text, and the values are the entities found.

Example input:

April 7 (Bloomberg) — Yahoo! Inc., the Internet company that snubbed a $44.6 billion takeover bid from Microsoft Corp., may drop in Nasdaq trading after the software maker threatened to cut its bid if directors fail to give in soon.

If Yahoo’s directors refuse to negotiate a deal within three weeks, Microsoft plans to nominate a board slate and take its case to investors, Chief Executive Officer Steve Ballmer said April 5 in a statement. He suggested the deal’s value might decline if Microsoft has to take those steps.

The ultimatum may send Yahoo Chief Executive Officer Jerry Yang scrambling to find an appealing alternative for investors to avoid succumbing to Microsoft, whose bid was a 62 percent premium to Yahoo’s stock price at the time. The deadline shows Microsoft is in a hurry to take on Google Inc., which dominates in Internet search, said analysts including Canaccord Adams’s Colin Gillis.

Example output:

    [Industry Term] => Array
            [0] => Internet
            [1] => software maker
            [2] => Internet search
    [Person] => Array
            [0] => Steve Ballmer
            [1] => Jerry Yang
            [2] => Colin Gillis
    [Company] => Array
            [0] => Google Inc.
            [1] => Canaccord Adams
            [2] => Yahoo!
            [3] => Microsoft Corp.
    [Currency] => Array
            [0] => USD
    [SocialTag] => Array
            [0] => New encyclopedism
            [1] => Microsoft
            [2] => Jerry Yang
            [3] => Steve Ballmer
            [4] => Bing
            [5] => Yahoo!
            [6] => Internet search engines
            [7] => Hypertext

Basic usage is simple. Create an instance of the class with your API key, and call the getEntities method using your content string.

$oc = new OpenCalais('your-api-token');
$entities = $oc->getEntities($content);

This class is distributed under an open source BSD license. The license terms can be found in license.txt of the code archive.

  • Kev

    Anyone to create and maintain a WordPress plugin for tags auto-suggestion ? 🙂

  • David Peterson


  • Dan

    Kev: I’m hoping to work on that some time this week when I get the chance.

  • Neha

    hey Dan…
    i am new to this.Just downlaoded your source files and tryingto run it..
    can you please tell me how to use your calais class..
    $entities = $oc->getEntities($content);
    the function getEntities returns empty string..
    i have placed proper key in the source code..
    are there any pre-requisites..
    i downloaded calais-client..bu not able to execute submissio-tool.bat…
    can you please help

  • Dan

    Neha: Does $content contain a string of English content with entities Calais will recognize?

    Kev: The initial WordPress plugin for tag suggestion’s now available here:

  • Pingback: Dan Grossman » WP Calais Auto Tagger: Automatic Tag Suggestion For Your Posts()

  • Neha

    The content is same as your example input.
    I was just trying to run your source code. Downloaded the zip and put it in my web folder and added my Licenseid.Do I need to do anything else.

  • Pingback: Dan Grossman » Tagging Large Post Archives Automatically()

  • Pingback: PHP Weekly Reader - April 13th 2008 : phpaddiction()

  • Neha

    hey dan can you tell me some place where i can test ur PHP class..
    or give me the sample input…

  • Dan

    Neha: The sample output above came directly from the example input above.

  • nico.

    Hey Dan,

    Thanks a lot for the file!

    I just think you forgot ‘Country’ on line 75 😉


  • Dan

    Thanks for mentioning that nico, I’ve added it here and in the copy bundled with the plugins.

  • Neha

    Hi Dan,

    I know that Dan. I downloaded the zip class file for php.Hosted it on my web. And added my API key in octest.php.I am trying to run it. I get an error saying
    Warning: Invalid argument supplied for foreach() in C:\wamp\www\opencalais\octest.php on line 27

    $response = html_entity_decode(curl_exec($ch));
    this line returns nothing

    Can you please tell me whats wrong

    Do I need anything else except the API key to use your class.

  • Pingback: the eXternal mind » links for 2008-05-13()

  • Tom

    Hey Dan,

    Was using your OC class on my site and had such a breeze getting it working forgot all about it. Now it seems that something might have changes with the OC API as now it always returns no suggestions. Have you released a new version in line with the new API if it has indeed changed?


  • Pingback: Dan Grossman » Open Calais PHP Class Updated()

  • Andy

    @Neha: If you havent got it working yet, may be you might want to check your php.ini ( if on windows ) for whether this line extension=php_curl.dll
    is uncommented or not and if the dll is actually in place.

    Just ran the example today. Seems to work fine without any alteration to code itself.

    Great job mate thanks. I am now going to try and combine this with Lucene.
    Just a query about your WP exploits. Did you manage to get it working. If so I believe you would be storing the tags into a database? If so could you give me a hint on the table structure.


  • Dan

    @Andy: WordPress supports tags out of the box, you don’t need your own database. WP Calais Auto Tagger, WP Calais Archive Tagger

  • Andy

    oh.. ok.
    i thought i read that you were going to work on something like that?
    haha may be i was sleep reading. anyway thanks for the links

  • Andy

    oh and i forgot to mention the query about the tags wasnt for WP itself.
    i am working on a different sort of application in which auto-tagging would help and just thought what was the optimum way to execute a tags DB.
    now that you have implemented it for WP i shall snoop around and dig in, to have a look at the data handling and the table structure.


  • Benjamin Hourigan

    When I try to activate the WP Calais Auto Tagger plugin in WP 2.6.1, I get this error:

    Parse error: syntax error, unexpected T_CONST, expecting T_OLD_FUNCTION or T_FUNCTION or T_VAR or ‘}’ in /home/18214/domains/ on line 17

    What is happening?

  • Dan

    You don’t have PHP 5, Ben.

  • Benjamin Hourigan

    Thanks, Dan.

  • Sammy Kanan


    Is there any chance of using https instead of http in the request?

  • Lee

    According to

    “HTTP POST – Obsolete

    In older versions you could also invoke the service via an HTTP POST request using the following URL:”

    Does this mean this is about to be obsolete since that URL is what you use?

  • Dan

    Hi Lee, it looks like HTTP POST is still supported but they’ve changed the URL a little. I’ll try to update the class and plugins soon.

  • Pingback: Dan Grossman | Calais Class and Plugins Updated()

  • Drapetomaniac

    Your post says it’s licensed BSD. In the next version, can you put that in the license file?

    I’ll point people this way as the origin and include the original license, but just having a copyright notice without mentioning BSD makes me concerned about using it for come clients. My plan is to use to to start something for Joomla and open it up.

    (I spend time instructing and educating others on open source, etc, so I’m all for reducing ambiguity)

    Thanks for this class!

  • Hetal

    I recently came across OpenCalais and was looking around ways to use with PHP and your class is a real life saver… Thank you very much and will let you know if I face any issues. Thanks again.

  • narcoti

    printable weight loss chart

  • wwwsoni

    blackjack 98 return

  • wwwaffo

    sandia resort casino

  • wwwaudi

    pioneer dvrk05l dual layer slot loading drive

  • casinof

    wwwtopsitecentralcom online casinos free

  • ebooksp

    photonics drug information

  • blackja

    free multiline slots

  • socketa

    bum slot cars

  • masquev

    las vegas 98 slot pay back

  • luxorho

    wwwaffordablemovingcompanycom online casinos free

  • slotmac

    wwwtopsitecentralcom online casinos free

  • fatburn

    got pregnant with first cycle of clomid will it work again

  • propeci

    drug testing xanex

  • nationa

    breast lift weight loss results

  • casinon

    3qa roulette

  • cheroke

    easter seals land lake poker run

  • somatic

    yamato engine specialists

  • rjslots

    wwwpaisleycreekcom free online slots

  • diabete

    amateur html index link mature tutularsoman tu funpic org

  • financi

    over the counter pain medications