Sharing Analytics API \ Initiate a new snapshot

Resource/URI GET POST PUT DELETE
Sharing Analytics Snapshots /sharing/analytics/snapshots.json List all snapshots Initiate a new snapshot
Sharing Analytics Snapshot /sharing/analytics/snapshots/<sharing_analytics_snapshot_token>.json Retrieve snapshot details Delete a snapshot

Workflow 1 - Without using a pingback PHP SDK

We do not recommend to use this method and the repeatedly polling. You should use a pingback if possible.

Request: the code to send to the API

Send a PUT request to the resource /sharing/analytics/snapshots.json and include the structure below as POST data to initiate a snapshot of a previously published message. You can only request one snapshot at a time for a given sharing_message_token.

Our API will queue the operation and return a sharing_analytics_snapshot_token that you can use to retrieve the status and the details of the snapshot. You must try to retrieve the snapshot at regularly intervals until it's available.

POST data to include in your request

		{
			"request": {
				"analytics": {
					"sharing": {
						"sharing_message_token": "#sharing_message_token#"
					}					
		    }
		  }
		}
Key Description
* #sharing_message_token# The unique token a message published using our Advanced Sharing API.
Example: a1ddb4d0-9263-4872-b0e7-18a5565bf78b

Result: the code returned by the API

The API may return one of the following status codes:

  • 201: The snapshot has successfully been scheduled;
  • 207: There is already a pending snapshot for the given message;
  • xxx: An error occured while processing the request.

Example Resultset

		{
		  "response": {
		    "request": {
		      "date": "Fri, 27 Jan 2012 16:08:37 +0100",
		      "resource": "/sharing/analytics/snapshots.json",
		      "status": {
		        "flag": "scheduled",
		        "code": 201,
		        "info": "Your request has been received and scheduled to be processed"
		      }
		    },
		    "result": {
		      "data": {
		        "sharing_analytics_snapshot": {
		          "sharing_analytics_snapshot_token": "ace99ec8-969d-462d-a93d-ae896ddffdba",
		          "date_initiated": "Fri, 27 Jan 2012 16:08:37 +0100",
		          "sharing_message": {
		            "sharing_message_token": "221c7bdf-d2b7-4ee4-99f4-34d0d550ecf6",
		            "date_creation": "Tue, 24 Jan 2012 23:38:55 +0100",
		            "date_last_published": "Tue, 24 Jan 2012 23:38:56 +0100"
		          }
		        }
		      }
		    }
		  }
		}

Workflow 2 - Using a pingback PHP SDK

We recommend to use this method over the repeatedly polling of the API.

Request: the code to send to the API

Send a PUT request to the resource /sharing/analytics/snapshots.json and include the structure below as POST data to initiate a snapshot of a previously published message. Our API will queue the operation and send POST request to your pingback_uri once it's ready.

POST data to include in your request

		{
			"request": {
				"analytics": {
					"sharing": {
						"sharing_message_token": "#sharing_message_token#",
						"pingback_uri": "#pingback_uri"
					}					
		    }
		  }
		}
Key Description
* #sharing_message_token# The unique token a message published using our Advanced Sharing API.
Example: a1ddb4d0-9263-4872-b0e7-18a5565bf78b
* #pingback_uri# The pingback_uri is an url on your server that can handle the resultant response. After having build the snapshot, our API will send a POST request to the pingback script; an example is available here.
Example: http://www.example.com/sharing-analytics/pingback.php

Result: the code posted by our API to the given pingback uri

		{
		  "response": {
		    "request": {
		      "date": "Fri, 27 Jan 2012 16:10:03 +0100",
		      "resource": "/sharing/analytics/snapshot.json",
		      "status": {
		        "flag": "success",
		        "code": 200,
		        "info": "Your request has been processed successfully"
		      }
		    },
		    "result": {
		      "data": {
		        "sharing_analytics_snapshot": {
		          "sharing_analytics_snapshot_token": "ace99ec8-969d-462d-a93d-ae896ddffdba",
		          "date_initiated": "Fri, 27 Jan 2012 16:08:37 +0100",
		          "date_finished": "Fri, 27 Jan 2012 16:10:03 +0100",
		          "sharing_message": {
		            "sharing_message_token": "221c7bdf-d2b7-4ee4-99f4-34d0d550ecf6",
		            "date_creation": "Tue, 24 Jan 2012 23:38:55 +0100",
		            "date_last_published": "Tue, 24 Jan 2012 23:38:56 +0100"
		          }
		        }
		      }
		    }
		  }
		}

User Contributed Notes