×

Error message

  • Warning: array_merge(): Argument #2 is not an array in superfish_block_view() (line 924 of /var/www/rhizome/data/www/developers.contentglass.com/drupal/sites/all/modules/superfish/superfish.module).
  • Warning: array_merge(): Argument #1 is not an array in superfish_block_view() (line 1035 of /var/www/rhizome/data/www/developers.contentglass.com/drupal/sites/all/modules/superfish/superfish.module).

Create Server Widget

The operation let you send HTTP request for creating a widget using the Server Widgets API

Request Parameters: 
  • app_id  - the application Id. Unless you set dedicated application use this value: "server_widgets"   
  • api_key - The API key assigned to service provider.  For trial version use this value:  "demo_developer-prod"
  • glass_id - String that represent the sharing context state. In the case of sharing in the context of webpage this will be the URL of the webpage. However depending on the application this can be some code, and advanced application can also used an addition state dimensions (e.g location) to refer to sharing context state.
  • glass_type - the type of the sharing context. Below are currently supported types:
    • 1.1 - webpage
    • 1.2 - web domain
    • 1.3 - top level web domain
  • widget_type - The type of widget to create. Currently supported values:
    • "cg-APIHTMLWidget" - widget that contains custom HTML to present some content.
  • peers - array of peers. One of the peers must be marked as owner.
  • data - the data to set in the widget. For now since cg-APIHTMLWidget is the only supported widget this will be some HTML script or simple text.  

 

Sample Code: 
<?php

$params = array(
    "app_id" => "[APP ID]",
    "api_key" => "[API_KEY]",
    "glass_id" => "website_tools.contentglass.com",
    "glass_type" => "1.2",
    "widget_type" => "cg-APIHTMLWidget",
    "peers" => array(
        array("owner" => "true", "id" => "server_widget@rhizomenet.com", "notify" => false),
        array("email" => "tiram.gilad@gmail.com", "notify" => false),
    ),
    "data" => "
123456
", ); $serviceUrl = "http://api.contentglass.com/server_api/s1/server_widget"; $error = ""; $response = NetUtils::curlPOST($serviceUrl, $params, $error); echo "<h1>Test Widget Create</h1>"; echo "<pre>"; echo $response; echo "</pre>"; if (!empty($error)) { echo $error; } ?>
Sample Response: 
{
  "status": 1,
  "id": "5676627b45cc2",
  "data": {
    "invitations": {
      "tiram.gilad@gmail.com": "https://api.contentglass.com/server_api/p1/invitation/accept?id=1103"
    }
  }
}