Embedding twitter posts using publish-subscribe (no autopublish)

Hi guys,

I’m trying to embed tweets, using the twitter api. So far, so good. I’ve got the managed to get the embed codes from twitter, and i’ve managed to successfully embed them using autopublish,
But now, I want to to the same thing, using publish subscribe. I’ve written my methods, but apparently it does’n work.
I put all my embed codes in one array and publish it once because I had duplication problems it I added them one by one.

Here’s my code:


'twitterSearch': function(term) {
try {
  var connections = {}
  var html_embed = []
  var id
  var array = twitter.search(term)
  var content = JSON.parse(array['content'])
  content = content['statuses']

  for (var i = 0; i < content.length; i++) {
    id = content[i]['id_str']
    var rawEmbed = twitter.callAsApp('GET', 'statuses/oembed.json', {
      id: id
    rawEmbed = JSON.parse(rawEmbed['content'])

    //putting all embed codes in one big array
    html_embed.push({html: rawEmbed['html']})

  //and now I'm publishing it
  Meteor.publish('tweetPublication', function() {
    var init = true
    var subscription = this

    connections[subscription._session.id] = subscription

    subscription.added('tweets', Random.id(), tweet)

      delete connections[subscription._session.id]
} catch (e) {
  return null


Tweets = new Mongo.Collection('tweets')


<template name="tweet">
{{#each data}}
  {{> html_embed}}
{# <li>{{{html}}}</li> #}

<template name="html_embed">


{{#each tweets}}
  {{> tweet}}