Back to Documentation Overview

generateText

public static 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.

Section:
Helper
Parameters:
apikey a valid API Key for your user account. Get by calling login()
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

  1. <?php
  2. /**
  3. This Example shows how to submit HTML content and have a Text version of it
  4. returned using XML-RPC.
  5. Note that we are using the PEAR XML-RPC client and recommend others do as well.
  6. **/
  7. require_once 'XML/RPC2/Client.php';
  8. require_once 'inc/config.inc.php';
  9. try {
  10. $client = XML_RPC2_Client::create($apiUrl);
  11.  
  12. $html = '<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
  13. "http://www.w3.org/TR/html4/loose.dtd">
  14. <html lang="en"><head>
  15. <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  16. <title>untitled</title>
  17. <style>#header{width:935px;float:left;background:#fecb66;}</style>
  18. </head>
  19. <body><div id="header">
  20. <div id="header_content">Who Rocks?</div>
  21. <ul><li>Pink Floyd</li><li>Smashing Pumpkins</li></div>
  22. <div id="container"><div id="content"></div></div></body></html>';
  23.  
  24. $result = $client->generateText($apikey, "html", $html);
  25. echo "SUCCESS! \n";
  26. echo "Text Version:\n";
  27. echo $result;
  28. } catch (XML_RPC2_FaultException $e){
  29. echo "ERROR!!!!\n";
  30. echo $e->getFaultCode()." : ".$e->getFaultString()."\n";
  31. }
  32.  
Add New Note User Contributed Notes for generateText
No notes, yet... Will you be the first??