« Back to Documentation OverviewgenerateText – v1.1
generateText(string apikey, string type, mixed content)
Have HTML content auto-converted to a text-only format. You can send: plain HTML, an array of Template content, an existing Campaign Id, or an existing Template Id. Note that this will not save anything to or update any of your lists, campaigns, or templates.
| Parameters | xml-rpc_generateText.php| apikey | a valid API Key for your user account. Get by calling Get by visiting your API dashboard |
| type | The type of content to parse. Must be one of: "html", "template", "url", "cid" (Campaign Id), or "tid" (Template Id) |
| content | The content to use. For "html" expects a single string value, "template" expects an array like you send to campaignCreate, "url" expects a valid & public URL to pull from, "cid" expects a valid Campaign Id, and "tid" expects a valid Template Id on your account. |
| Returns | | string |
the content pass in converted to text. |
Examples (1)
download example code
[1] xml-rpc_generateText.php
<?php
/**
This Example shows how to submit HTML content and have a Text version of it
returned using XML-RPC.
Note that we are using the PEAR XML-RPC client and recommend others do as well.
**/
require_once 'XML/RPC2/Client.php';
require_once 'inc/config.inc.php';
try {
$html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html lang="en"><head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>untitled</title>
<style>#header{width:935px;float:left;background:#fecb66;}</style>
</head>
<body><div id="header">
<div id="header_content">Who Rocks?</div>
<ul><li>Pink Floyd</li><li>Smashing Pumpkins</li></div>
<div id="container"><div id="content"></div></div></body></html>';
$result = $client->generateText($apikey, "html", $html);
} catch (XML_RPC2_FaultException $e){
echo $e->getFaultCode()." : ".$e->getFaultString()."\n"; }