Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
sending GET/POST responses
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  2 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Gerald Yeo  
View profile  
 More options Aug 14 2012, 9:15 pm
From: Gerald Yeo <gerald....@gmail.com>
Date: Tue, 14 Aug 2012 18:15:41 -0700 (PDT)
Local: Tues, Aug 14 2012 9:15 pm
Subject: sending GET/POST responses

Hi group,

I'm new to node and flatiron.

I'm trying to use flatiron to create an app that uses Instagram's realtime
api. So the first step is to handle the subscription, and I'm stumbling on
sending back the hub.challenge response.

I tried looking at the examples in GitHub, the closes that I can get is the
app.res.json function.

Can anyone point me in the right direction, either to documentation or
examples?

Here's my starting app...

var flatiron = require('flatiron'),
    qs = require('qs');

// declarations
var instagramClientId = 'ID',
    instagramClientSecret = 'SECRET',
    app = flatiron.app;

app.use(flatiron.plugins.http);

app.router.configure({ 'strict':false });

//----- routes --------------------------------------------------
// index
app.router.get('/', function () {
    this.res.writeHead(200, {'content-type':'text/plain'});
    this.res.end('index');

});

// callback
app.router.path('/callback', function () {
    // GET /callback
    // If param hub.challenge is present, renders its value
    // This URL is used by subscription system of Instagram
    // to check if the callback URL provided when creating the subscription
    // is valid and works fine
    this.get(function () {
        if (this.req.query['hub.challenge'] != null) {
            //this.res.send(this.req.query['hub.challenge']);
            console.log(this.res)
        }
        else {
            app.log.info("ERROR on subscription request: %s");
        }
    });

    // post
    this.post(function () {
        // @todo
        this.res.writeHead(200, { 'content-type':'text/plain' });
        this.res.end('hello!');
    });

});

// start the server
app.start(8080, function (err) {
    if (err) {
        throw err;
    }

    var addr = app.server.address();
    app.log.info('listening on http://' + addr.address + ':' + addr.port);


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Gerald Yeo  
View profile  
 More options Aug 14 2012, 10:52 pm
From: Gerald Yeo <gerald....@gmail.com>
Date: Tue, 14 Aug 2012 19:52:47 -0700 (PDT)
Local: Tues, Aug 14 2012 10:52 pm
Subject: Re: sending GET/POST responses

ok, so I may have solved my own problem :)

Basically this two lines did it...
this.res.writeHead(200, { 'content-type':'text/plain' });
this.res.end(this.req.query['hub.challenge']);


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »