Communify PHP SDK

Most Viewed Article

The Communify SDK for PHP enables PHP developers to use Communify Web Services in their PHP code. You can get started in minutes by installing the SDK through Composer or by downloading a single zip or phar file from our latest release.

1. Features

– Single Sign On (SSO)
Using our SSO integration will create a seamless session/user authentication process. Your site members will be automatically logged into your Communify widgets so your logged visitors will be able to join conversations without any previous step. Non-logged visitors will be redirected to your login/sign in page before joining the conversation.

– Search Engine Optimization (SEO)
Use our SEO integration to add all user contents gathered from conversations and reviews to your pages HTML as a valuable SEO friendly content.

– Review request – email after purchase (EAP)
Using our EAP integration Communify can schedule review request emails to all customers that purchased products on your store and collect their feedback to feed your product pages with reviews.

2. Getting Started

Sign up at Communify:
  • Go to and create your account.
Get your account ID and setup basic settings from your dashboard:
  • Go to Settings > Integration and note yout Account ID from the script data.
<di id="communify-widget-id" data-account-slug="[ACCOUNT SLUG]" data-account-id="[ACCOUNT ID]"><div ui-view class="communify-widget"></div></div>
  • Set your preferences from settings > General, membership and notifications.
    If you are planning to use unique user sessions remember to enable Single Sign On login (Go to Settings > Membership)
Minimum requirements:

PHP version: >= 5.3.0
Guzzle: 3.7
Mustache: 2.5


2.3. Install the SDK

2.3.1. Using composer

If your site or app is using Composer you only will need to load our library.

Modify composer.json:
"require": {
"communify/communify-php": "dev-master",

Execute composer update.


2.3.2. Without using composer

If your site or app is not using Composer you could also load Communify library easily. Just download our latest SDK and follow a few steps.


Add communify_sdk folder at project, and include autload.php to use Communify SDK.


3. Examples

3.1. Single Sign On (S2O)

After installing our SDK you only have to paste the following code fullfilling the spaces with your communify account information and the current user session.


 $accountId = '[ACCOUNT ID]';
    $data = array(
        'email'             => '[USER EMAIL]',
        'name'              => '[USER NAME]',
        'surname'           => '[USER SURNAME]',
        'file_url'          => '[USER IMAGE URL]',
        'language_id'       => '[LANG ID]'
    echo \Communify\S2O\S2OClient::factory()->login($accountId, $data)->metas();

3.1.1. Single Sign On (SSO) and WordPress

If you are using WordPress you can get SSO working just pasting the following code on your pages (after installing our SDK )

function getAvatarUrl($id)
        $avatar = get_avatar($id);
        preg_match("/src=\"(.*?)\"/i", $avatar, $matches);
        $url = $matches[1];
        $urlArray = parse_url($url);
        return 'http://'.$urlArray['host'].$urlArray['path'];

    $currentUser = wp_get_current_user();
    $accountId = '[ACCOUNT ID]';
    if($currentUser->ID != 0)
        $data = array(
            'email'             => $currentUser->user_email,
            'name'              => $currentUser->user_firstname,
            'surname'           => $currentUser->user_lastname,
            'file_url'          => getAvatarUrl($currentUser->ID)
        echo \Communify\S2O\S2OClient::factory()->login($accountId, $data)->metas();

3.2. Search Engine Optimization (SEO)

If you have a Professional plan you can also bring your community contents your page as a fully browsable HTML content for search engines. Just add this code tag to your pages.

    $accountId = '[ACCOUNT ID]';
    $data = array(
        'limit'             => '10',
        'order_by'          => 'date'

    echo \Communify\SEO\SEOClient::factory()->widget($accountId, $data)->html();

3.2. Review requests Email after purchase (EAP)


  • All product lines have same user
  • All product lines have same order_id
  • Some product line fields are mandatories: orderId, price, productId, userEmail.


  $accountId = '[ACCOUNT ID]';
    $productLine1 = array(
        'order_id'              => [ORDER ID],
        'price'                 => [PRICE],
        'product_id'            => [PRODUCT/TOPIC ID],
        'product_name'          => [PRODUCT/TOPIC NAME],
        'title'                 => [PRODUCT/TOPIC TITLE],
        'location_url'          => [PRODUCT/TOPIC URL]
        'title_to_display'      => [PRODUCT/TOPIC TITLE TO DISPLAY],
        'description'           => [PRODUCT/TOPIC DESCRIPTION],
        'site_image_url'        => [PRODUCT/TOPIC IMAGE URL],
        'category_slug'         => [CATEGORY SLUG],
        'category_name'         => [CATEGORY NAME],
        'category_description'  => [CATEGORY DESCRIPTION],
        'user_name'             => [CUSTOMER NAME],
        'user_surname'          => [CUSTOMER SURNAME],
        'user_email'            => [CUSTOMER EMAIL],            
    $order = array($productLine1, [$productLine2, ...]);

    \Communify\EAP\EAPClient::factory()->setOrder($accountId, $order);



If you find any issue or have questions please don’t hesitate to contact us thought your communify dasboard > User > Contact support or using the forums.


About The Author


Rate This Article

(56 out of 110 people found this article helpful)

Leave A Comment?