0

I currently use HTTPGet to generate our subject lines. This method has proven unreliable in how it handles apostrophes and quotes since it ignores all encoding. Even forcing UTF in the PHP does not help.

To avoid this, how can I use a JSON or RSS feed to populate the subject line?

  %%=TreatAsContent(HTTPGet("http://www.site.com/subject_daily.php"))=%%
5
  • 1
    You can use a JSON or RSS feed to populate the subject line. My personal preference would be JSON. If you can provide an example feed then I'd be happy to provide a code example. I just need clarification on what the feed will look like. For example, will the JSON feed contain a single name/value pair of the subject line, or will it contain a subject lines for each date like this sample gist? You could then populate the subject line based on the current date at send time. Please let me know your preference. Aug 9, 2016 at 18:17
  • Actually, with further testing, it seems the issue is with SFMC Programs. My subject line is fine until the email is sent via a Program schedule. But I'm still interested in this solution, here's a test feed: 66.228.46.202/index.php/wp-json/wp/v2/test-api?_embedded'
    – ok1ha
    Aug 9, 2016 at 19:06
  • 1
    I'd highly recommend migrating your Program to an Automation in Automation Studio and see if you get the same result. FYI, Programs will sunset in January 2017. Salesforce will shortly release an 'easy upgrade wizard' to migrate Programs to Automations. In the meantime, I'll put together a sample working solution for you. Aug 9, 2016 at 19:10
  • Ok, thanks. I sent another test as an automation and the ASCII issue is still happening. And thank you for your help in regards to the feed.
    – ok1ha
    Aug 9, 2016 at 19:43
  • Did you see my answer? Does that work for you? Aug 12, 2016 at 3:01

1 Answer 1

1

To achieve this, I'm going to use AMPscript in conjunction with Guide Template Language (GTL) to parse the JSON object.

I'm assuming that you want to display the rendered value inside the title object from your JSON feed. In this case, you will need to set two datasources in GTL; one datasource to define the JSON object and a second datasource to retrieve the nested title object.

Paste the following code in your subject line:

%%[
var @subjectLineFeed
set @subjectLineFeed = HTTPGet('http://66.228.46.202/index.php/wp-json/wp/v2/test-api?_embedded%27')
]%%

{{.datasource subjectLineFeed type=variable}}
   {{.data}}
      {"target":"@subjectLineFeed"}
   {{/data}}

   {{.datasource subjectLine type=nested}}
      {{.data}}
        {"target":"subjectLineFeed.title"}
      {{/data}}

{{subjectLine.rendered}}

   {{/datasource}}
{{/datasource}}

This renders the subject line as:

“This is a #test for test’s”

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .