JSON

RevPlaza

New Member
Hi,

I am going to use MailWizz to send articles based on users' interests using JSON. I have my own script which generates JSON with the right articles for each user.

The script selects 8 best matching articles for the user. The email subject should be the title of the first article.

Right now, I use something like that in the subject:
[JSON_FEED_BEGIN url='[URL]http://domain/script-json.php?user=[SUBSCRIBER_UID]'][JSON_FEED_ITEM_TITLE][JSON_FEED_END[/URL]]

In the newsletter, I am calling again the JSON script:
[JSON_FEED_BEGIN url='[URL]http://domain/script-json.php?user=[SUBSCRIBER_UID][/URL]' count='8']

Is is possible to achieve that without calling the JSON twice (once in the subject field and once in the newsletter)?
 
Thank you for the clarification.

I set up the email subjects this way - [JSON_FEED_BEGIN url='[URL='http://domain/script-json.php?user=[SUBSCRIBER_UID]%27][JSON_FEED_ITEM_TITLE][JSON_FEED_END']http://domain/script-json.php?user=[SUBSCRIBER_UID]'][JSON_FEED_ITEM_TITLE][JSON_FEED_END[/URL]] - however, it does not work as expected. When the campaign sends more than one newsletter, Instead of selecting the article title for each subscriber, all subscribers receive the same subject. The problem is only with the subject, in the email body it works fine and everybody gets his personalized content.

I have found a message in this forum which suggests that the subject generated by JSON is cached. I also checked my server logs and they confirm that the JSON script used in the subject field was called only once (while there was 9 newsletters sent). It sounds like a great feature because it saves a lot of MySQL queries, however, when a custom field is present in the JSON URL I believe it should not be cached.

If my supposition is correct:
1. Is there some way how to turn off the caching? I searched in the backend section but did not found it.
2. If not, can you tell me please which file contains the code responsible for the caching? As having correct subject generated this way is very important for my strategy, I would try to edit the script.

Thanks!
 
@RevPlaza - You are correct related to caching, and you could disable this by opening /apps/common/components/utils/CampaignXmlFeedParser.php and at around line 57-59 where you have:
PHP:
if ($cache && ($cachedContent = Yii::app()->cache->get($cacheKey))) {
    return $cachedContent;
}
Simply remove that and save the file, that should prevent getting content from cache.
 
Back
Top