{"__v":3,"_id":"570fa6cab85a841900aa9567","category":{"project":"56abbf55f25f160d00e17f4e","version":"56abbf55f25f160d00e17f51","_id":"570a5676ade45d0e00c1ad33","__v":0,"sync":{"url":"","isSync":false},"reference":true,"createdAt":"2016-04-10T13:34:46.864Z","from_sync":false,"order":3,"slug":"client-side-api","title":"Client Side API"},"parentDoc":null,"project":"56abbf55f25f160d00e17f4e","user":"56abbec30b9e0b0d00616274","version":{"__v":12,"_id":"56abbf55f25f160d00e17f51","project":"56abbf55f25f160d00e17f4e","createdAt":"2016-01-29T19:36:53.665Z","releaseDate":"2016-01-29T19:36:53.665Z","categories":["56abbf56f25f160d00e17f52","56abca6bf9757e0d007c6650","56acddfa0ab3c00d00ce3332","56af65da9d32e30d0006d30f","56af66cab34d210d003d9ad0","56af6afcd21e9c0d00b628d1","56af6d6ecc4cbd0d00ce2c88","5705b12221cfed0e00e8c580","570a5676ade45d0e00c1ad33","570d7d25d1e4b82000d9e385","570eac3c3160d10e0041df0e","575709000fd6a3200010dded"],"is_deprecated":false,"is_hidden":false,"is_beta":false,"is_stable":true,"codename":"","version_clean":"1.0.0","version":"1.0"},"updates":[],"next":{"pages":[],"description":""},"createdAt":"2016-04-14T14:18:50.604Z","link_external":false,"link_url":"","githubsync":"","sync_unique":"","hidden":false,"api":{"results":{"codes":[]},"settings":"","auth":"required","params":[],"url":""},"isReference":true,"order":28,"body":"[block:callout]\n{\n  \"type\": \"warning\",\n  \"title\": \"Note\",\n  \"body\": \"This API currently functions best using the ActionScript 3 API. It can be used from the JavaScript API, but thumbnail behavior will be undefined.\"\n}\n[/block]\n## Saving content\n\nYou can use the `save` function on the `sharedContent` property of the Kongregate API object to submit shared content on the Kongregate back-end. It accepts a type, content string, callback, and optionally a thumbnail and a label:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`type`\",\n    \"0-1\": \"String\",\n    \"0-2\": \"Type of content the user wishes to save, 12 characters max\",\n    \"1-0\": \"`content`\",\n    \"1-1\": \"String\",\n    \"1-2\": \"Value of content to be saved. We strongly recommend keeping these values under 100K since the game will hang until the content is sent, which can lead to a poor user experience if the content is too large\",\n    \"2-0\": \"`callback`\",\n    \"2-1\": \"Function\",\n    \"2-2\": \"Function to be called when the operation is completed\",\n    \"3-0\": \"`thumbnail`\",\n    \"3-1\": \"DisplayObject\",\n    \"3-2\": \"Optional, but highly recommended! Send us a DisplayObject that we will snapshotted and used as a thumbnail for the content. If this is not provided we will take a picture of the entire stage and use that as the thumbnail.\",\n    \"4-0\": \"`label`\",\n    \"4-1\": \"String\",\n    \"4-2\": \"Optional label for sub-classing the shared content.\"\n  },\n  \"cols\": 3,\n  \"rows\": 5\n}\n[/block]\nThe callback method will be passed a single object with the following attributes:\n[block:parameters]\n{\n  \"data\": {\n    \"h-0\": \"Name\",\n    \"h-1\": \"Type\",\n    \"h-2\": \"Description\",\n    \"0-0\": \"`success`\",\n    \"0-1\": \"Boolean\",\n    \"0-2\": \"Flag indicating whether or not the operation was successful\",\n    \"1-0\": \"`id`\",\n    \"1-1\": \"Integer\",\n    \"1-2\": \"Unique ID of the created shared content\",\n    \"2-0\": \"`name`\",\n    \"2-1\": \"String\",\n    \"2-2\": \"Name of the shared content\",\n    \"3-0\": \"`permalink`\",\n    \"3-1\": \"String\",\n    \"3-2\": \"Link to the shared content\",\n    \"4-0\": \"`content`\",\n    \"4-1\": \"String\",\n    \"4-2\": \"The content itself\",\n    \"5-0\": \"`label`\",\n    \"5-1\": \"String\",\n    \"5-2\": \"The label for the shared content\"\n  },\n  \"cols\": 3,\n  \"rows\": 6\n}\n[/block]\n**Example:** Save some shared content to as a `Contraption` with the contents `x1y3z10`, calling back `onContraptionSaved` using `myContraptionEditor` for the thumbnail and with the label `Level 3 Solution`\n[block:code]\n{\n  \"codes\": [\n    {\n      \"code\": \"kongregate.sharedContent.save('Contraption', 'x1y3z10', onSaved,                         \\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t myContraptionEditor,'Level 3 Solution');\\n\\nfunction onSaved(params:Object):void {\\n  if (params.success) {\\n    // The shared content was saved successfully.\\n    trace(\\\"Content saved, id:\\\" + params.id + \\\", name:\\\" + params.name);\\n  } else {\\n    // The shared content was not saved.\\n    // The most likely cause of this is that the User dismissed the save dialog  \\n  }\\n}\",\n      \"language\": \"javascript\",\n      \"name\": \"ActionScript 3\"\n    },\n    {\n      \"code\": \"kongregate.sharedContent.save('Contraption', 'x1y3z10', onSaved,                         \\t\\t\\t\\t\\t\\t\\t\\t\\t\\t\\t myContraptionEditor,'Level 3 Solution');\\n\\nfunction onSaved(params) {\\n  if (params.success) {\\n    // The shared content was saved successfully.\\n    console.log(\\\"Content saved, id:\\\" + params.id + \\\", name:\\\" + params.name);\\n  } else {\\n    // The shared content was not saved.\\n    // The most likely cause of this is that the User dismissed the save dialog  \\n  }\\n}\",\n      \"language\": \"javascript\"\n    }\n  ]\n}\n[/block]\nRelated:\n\n* [SharedContent.Browse](doc:sharedcontentbrowse) \n* [SharedContent.AddLoadListener](doc:client-api-sharedcontent-addloadlistener)","excerpt":"Save a custom level or other shared content\n`save(type, content, callback, thumbnail, label)`","slug":"client-api-sharedcontent-save","type":"fn","title":"SharedContent.Save"}

SharedContent.Save

Save a custom level or other shared content `save(type, content, callback, thumbnail, label)`

[block:callout] { "type": "warning", "title": "Note", "body": "This API currently functions best using the ActionScript 3 API. It can be used from the JavaScript API, but thumbnail behavior will be undefined." } [/block] ## Saving content You can use the `save` function on the `sharedContent` property of the Kongregate API object to submit shared content on the Kongregate back-end. It accepts a type, content string, callback, and optionally a thumbnail and a label: [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "`type`", "0-1": "String", "0-2": "Type of content the user wishes to save, 12 characters max", "1-0": "`content`", "1-1": "String", "1-2": "Value of content to be saved. We strongly recommend keeping these values under 100K since the game will hang until the content is sent, which can lead to a poor user experience if the content is too large", "2-0": "`callback`", "2-1": "Function", "2-2": "Function to be called when the operation is completed", "3-0": "`thumbnail`", "3-1": "DisplayObject", "3-2": "Optional, but highly recommended! Send us a DisplayObject that we will snapshotted and used as a thumbnail for the content. If this is not provided we will take a picture of the entire stage and use that as the thumbnail.", "4-0": "`label`", "4-1": "String", "4-2": "Optional label for sub-classing the shared content." }, "cols": 3, "rows": 5 } [/block] The callback method will be passed a single object with the following attributes: [block:parameters] { "data": { "h-0": "Name", "h-1": "Type", "h-2": "Description", "0-0": "`success`", "0-1": "Boolean", "0-2": "Flag indicating whether or not the operation was successful", "1-0": "`id`", "1-1": "Integer", "1-2": "Unique ID of the created shared content", "2-0": "`name`", "2-1": "String", "2-2": "Name of the shared content", "3-0": "`permalink`", "3-1": "String", "3-2": "Link to the shared content", "4-0": "`content`", "4-1": "String", "4-2": "The content itself", "5-0": "`label`", "5-1": "String", "5-2": "The label for the shared content" }, "cols": 3, "rows": 6 } [/block] **Example:** Save some shared content to as a `Contraption` with the contents `x1y3z10`, calling back `onContraptionSaved` using `myContraptionEditor` for the thumbnail and with the label `Level 3 Solution` [block:code] { "codes": [ { "code": "kongregate.sharedContent.save('Contraption', 'x1y3z10', onSaved, \t\t\t\t\t\t\t\t\t\t\t myContraptionEditor,'Level 3 Solution');\n\nfunction onSaved(params:Object):void {\n if (params.success) {\n // The shared content was saved successfully.\n trace(\"Content saved, id:\" + params.id + \", name:\" + params.name);\n } else {\n // The shared content was not saved.\n // The most likely cause of this is that the User dismissed the save dialog \n }\n}", "language": "javascript", "name": "ActionScript 3" }, { "code": "kongregate.sharedContent.save('Contraption', 'x1y3z10', onSaved, \t\t\t\t\t\t\t\t\t\t\t myContraptionEditor,'Level 3 Solution');\n\nfunction onSaved(params) {\n if (params.success) {\n // The shared content was saved successfully.\n console.log(\"Content saved, id:\" + params.id + \", name:\" + params.name);\n } else {\n // The shared content was not saved.\n // The most likely cause of this is that the User dismissed the save dialog \n }\n}", "language": "javascript" } ] } [/block] Related: * [SharedContent.Browse](doc:sharedcontentbrowse) * [SharedContent.AddLoadListener](doc:client-api-sharedcontent-addloadlistener)