Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Instagram node #27

Merged
merged 1 commit into from
Oct 10, 2014
Merged

Instagram node #27

merged 1 commit into from
Oct 10, 2014

Conversation

zobalogh
Copy link
Contributor

This is my attempt on the Instagram node. Current example is showing the query node. Comments are welcome. I'll squash commits once we get this work into a pullable state. Thanks

The pull request is now ready @knolleary .

var scoped_msg = clone(msg);


http.get(scoped_url, function(res) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knolleary , what do you think about using this http.get and specifying the 'binary' nature of the buffer? It will be deprecated in the future versions of node. However it isn't deprecated yet and is an easy way to buffer into memory.

There's a half-baked "buffer to disk" solution commented out. I'm not sure how I could trigger request to download to memory.

What's the best way forward here?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try request that we are already using elsewhere. The request callback has three parameters, the third being the body as a Buffer.

@zobalogh zobalogh force-pushed the instagram-node-dev branch 3 times, most recently from 61f1e89 to b3b99fd Compare October 1, 2014 13:57
@zobalogh zobalogh changed the title [wip]Instagram node dev Instagram node Oct 1, 2014
@zobalogh
Copy link
Contributor Author

zobalogh commented Oct 1, 2014

@knolleary I think the pull request is now in a state where you might want to take a look at it. Comments are welcome! The pull request has the initial requirements in it. Adding functionality such as location based information is to be defined and added later in a separate pull request. Thanks

@zobalogh zobalogh changed the title Instagram node [wip]Instagram node Oct 1, 2014
@zobalogh
Copy link
Contributor Author

zobalogh commented Oct 1, 2014

@knolleary pull request is in [wip] state again as I realised that currently when selecting the "photos uploaded by user" feature, it fetches all images uploaded by the user, ever. I'll need to fix this before we drop the node. Will let you know when this is fixed.

@zobalogh zobalogh changed the title [wip]Instagram node Instagram node Oct 1, 2014
@zobalogh zobalogh changed the title Instagram node [wip]Instagram node Oct 1, 2014
@zobalogh zobalogh changed the title [wip]Instagram node Instagram node Oct 1, 2014
@zobalogh
Copy link
Contributor Author

zobalogh commented Oct 1, 2014

@knolleary The pull request is now ready for review. Since my last comment I:

  1. discovered that the problem mentioned above was due to the inject node injecting a message into the Instagram node before it has initialized itself successfully. The uninitialized node defaults to the "user has not uploaded any known media" mode and thus it fetches everything. Now the node drops all incoming messages and ignores them if not initialized. It also warns the user. This is the simplest solution I could think of.

  2. As discussed, I simplified the output so now msg.filename doesn't exist any more and the node doesn't know anything about files/paths or anything related to a file system. For v1, this is the desired behaviour and additional message payload/property is to be determined later.

Thanks!

RED.nodes.addCredentials(node_id,credentials);
});

RED.httpAdmin.get('/instagram-credentials/auth/redirect', function(req, res) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hindessm , I managed to lose your comments when overwriting the pull request's branch with my local one. I made a response on your comment about the redirect url. I deliberately decided to choose a URI that's different from our current convention as I disagree with it. The user is setting up the "redirect URL" in most frameworks. Having redirect in the URL gives confirmation to the user that they're doing the right thing. Having callback here would just confuse the user as they'll start to wonder what that means... Yes, it's a callback from OUR perspective but a redirect from the user's perspective. So I propose to change all of them to redirect. Sorry, it stays as is for the time being!

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. However, the fitbit app configuration calls it "Callback URL" though so you shouldn't change that one and I think we want to be consistent. Since oauth calls it the oauth callback I suspect that continuing to use callback for consistency makes most sense.

Luckily I don't think users pay too much attention to the text of the URL they are cutting and pasting and you can write the accurate field name in the configuration hint to make sure they know exactly which field it needs to be pasted into.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, I'll change it then! I would still rather use my URI and just simply tag the function, if consistency is key. What do you think about adding a tag to each such callback?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you mean by 'tag the function'? As has been said, the urls were picked based on what oauth calls them. I don't see a compelling reason for this node to do something different.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was offering the option of having something in the path that actually
resembles what the given service calls the OAuth callback. This however
means that the callback URL will be different in some nodes. In order to
match them up, we could add a "callback" tag to all these express functions.

I'm considering that the different name (matching the service's on naming
convention) is for the user's convenience as in the instagram case, it's
called a "rediredt url" and if the user sees "redirect" in the URL, they're
more confident that they're copying the right field into the right place.

Mark says that as long as the instructions are clear, it doesn't matter
what the callback uri is and he'd therefore leave it as callback. I would
do the option I sketched up above.

Thanks

On 3 October 2014 12:05, knolleary notifications@github.com wrote:

In instagram/instagram.js:

  •    res.redirect(Url.format({
    
  •        protocol: 'https',
    
  •        hostname: 'api.instagram.com',
    
  •        pathname: '/oauth/authorize/',
    
  •        query: {
    
  •            client_id: credentials.client_id,
    
  •            redirect_uri: credentials.redirect_uri,
    
  •            response_type: "code",
    
  •            state: node_id + ":" + credentials.csrfToken
    
  •        }
    
  •    }));
    
  •    RED.nodes.addCredentials(node_id,credentials);
    
  • });
  • RED.httpAdmin.get('/instagram-credentials/auth/redirect', function(req, res) {

What do you mean by 'tag the function'? As has been said, the urls were
picked based on what oauth calls them. I don't see a compelling reason for
this node to do something different.


Reply to this email directly or view it on GitHub
https://github.com/node-red/node-red-web-nodes/pull/27/files#r18389821.

@zobalogh zobalogh force-pushed the instagram-node-dev branch 2 times, most recently from decd380 to 7900296 Compare October 3, 2014 10:26
@knolleary
Copy link
Member

The icon should not be the actual Instagram icon. Needs to conform to our icon requirements: http://nodered.org/docs/creating-nodes/appearance.html

@zobalogh
Copy link
Contributor Author

zobalogh commented Oct 3, 2014

I did want to use our conventions, however Instagram's terms and conditions
don't allow that. You can either use their icon (can pick black and white
or colour one) or nothing at all.
2. Brand Assets.

Use of Instagram's brand assets (e.g., the Instagram name and logo) is
governed by Instagram's Brand Guidelines
http://help.instagram.com/304689166306603, which are incorporated herein
by reference.

https://help.instagram.com/304689166306603/

which says:

Don’t:

  • Use the Instagram brand in a way that implies partnership, sponsorship
    or endorsement
  • Combine any part of the Instagram brand with your name, marks, designs
    or generic terms
  • Use trademarks, names, domain names, usernames, logos or other content
    that imitate or could be confused with Instagram
  • Present Instagram in a way that makes it the most distinctive or
    prominent feature of what you’re creating
  • Use any icons, images or trademarks to represent Instagram other than
    what is found on this page
  • Copy the Instagram look and feel

On 3 October 2014 14:12, knolleary notifications@github.com wrote:

The icon should not be the actual Instagram icon. Needs to conform to our
icon requirements: http://nodered.org/docs/creating-nodes/appearance.html


Reply to this email directly or view it on GitHub
#27 (comment)
.

@knolleary
Copy link
Member

Okay, but that doesn't mean we abandon our visual look. We should use a generic photo/picture icon.

@zobalogh
Copy link
Contributor Author

zobalogh commented Oct 3, 2014

I think that's exactly what their terms don't allow us. Do you read their
T&C differently to me?

Don't
Use any icons, images or trademarks to represent Instagram other than
what is found on this page

On 3 October 2014 14:29, knolleary notifications@github.com wrote:

Okay, but that doesn't mean we abandon our visual look. We should use a
generic photo/picture icon.


Reply to this email directly or view it on GitHub
#27 (comment)
.

@knolleary
Copy link
Member

From that same page:

Where color is limited, use the Glyph Logo in any color

So, please use their glyph icon in white.

@zobalogh
Copy link
Contributor Author

zobalogh commented Oct 3, 2014

OK! Do you have any problems with the current colour of the node? I used a
colour picker on their website's banner so the node's blue is in Instagram
colours!

On 3 October 2014 14:36, knolleary notifications@github.com wrote:

From that same page:

Where color is limited, use the Glyph Logo in any color

So, please use their glyph icon in white.


Reply to this email directly or view it on GitHub
#27 (comment)
.

@knolleary
Copy link
Member

I'd suggest something more like #889FB3 - similar in tone, just a bit lighter and in-keeping with our muted palette.

@zobalogh
Copy link
Contributor Author

zobalogh commented Oct 3, 2014

OK, thanks, I'll change the icon and the colour and push the new branch
with it.

On 3 October 2014 14:44, knolleary notifications@github.com wrote:

I'd suggest something more like #889FB3 - similar in tone, just a bit
lighter and in-keeping with our muted palette.


Reply to this email directly or view it on GitHub
#27 (comment)
.

@zobalogh
Copy link
Contributor Author

zobalogh commented Oct 3, 2014

@knolleary done

inputs:0,
outputs:1,
icon: "instagram.png",
align: "right",
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Input nodes should not have align set to right - it defaults to left, so you can remove this entry.

@zobalogh zobalogh force-pushed the instagram-node-dev branch 3 times, most recently from 9e2f517 to da61040 Compare October 6, 2014 10:28
@knolleary
Copy link
Member

Some comments:

  • can you put the Input node above the query node in the .html file - that affects the order they appear in the palette - input should be above query
  • can you and @hbeeken sync-up the appearance of the tip regarding callback url - this and the 4sq node look different. Don't mind which you two pick... just pick one.
  • The options in the edit dialog could do with some tweaks
    • 'Type'
      • suggest changing the text of the options to simply "User photos" and "Liked photos"
    • 'Output'
      • suggest changing the text of the options to: "the image as a buffer", "the image url"
  • Changing the poll interval to 15 minutes - that's consistent with our other polling nodes and is more respectful of the api limits.

@hbeeken
Copy link
Contributor

hbeeken commented Oct 6, 2014

@knolleary: regarding your comment "can you and @hbeeken sync-up the appearance of the tip regarding callback url - this and the 4sq node look different. Don't mind which you two pick... just pick one.", we've decided to go with Zoltan's wording as that sounds more general. However, this means that the google calendar node ( @hindessm ) needs updating to the same wording.

@zobalogh
Copy link
Contributor Author

zobalogh commented Oct 6, 2014

@knolleary I made all the changes you required above. I re-worded the node description and photos are now consistently called "photos". I also added a new paragraph to the node's description (last paragraph) to mention that the node currently only works with photos and not with videos.

@knolleary
Copy link
Member

The help text talks about setting msg.filename, which I don't believe is still in the code, so needs removing.

I don't think the query node is entirely clear about what it returns - what query does it actually do? (rhetorical question... don't need an answer here... the help needs updating to make it clear)

@zobalogh
Copy link
Contributor Author

zobalogh commented Oct 6, 2014

@knolleary I made the changes to the help txt as suggested by you. Thanks! I also updated the icon to be closer to the homepage's guidelines in terms of its dimension.

@zobalogh
Copy link
Contributor Author

zobalogh commented Oct 7, 2014

@knolleary All changes suggested by @hindessm are now done.

var ig = require('instagram-node').instagram();

// needed for normal operation
var clone = require('clone');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you still need to depend on clone? I don't see it used anywhere.

@zobalogh zobalogh force-pushed the instagram-node-dev branch 2 times, most recently from 785499e to 813226f Compare October 8, 2014 09:51
@zobalogh zobalogh changed the title Instagram node [wip]Instagram node Oct 8, 2014
ig.use({ access_token: credentials.access_token });
ig.user('self', function(err, result, remaining, limit) { // warning, this is not the same as the other result or res!
if (err) {
this.warn('Instagram node has failed to fetch the username : '+err);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@knolleary, marked my node as WIP again as it looks like this.warn is a bad choice for the auth process as it's this is undefined at this point! Noticed this when writing nock tests!

I think a more appropriate error message would be maybe to send a warning to res.send(). I'll fix this.

@zobalogh zobalogh changed the title [wip]Instagram node Instagram node Oct 8, 2014
knolleary added a commit that referenced this pull request Oct 10, 2014
@knolleary knolleary merged commit 8098f7b into node-red:master Oct 10, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants