Skip to content
This repository has been archived by the owner on Jul 9, 2022. It is now read-only.

Utility function for getting the image URL for a Messenger-style emoji #477

Merged
merged 4 commits into from
Jun 12, 2017

Conversation

GEOFBOT
Copy link
Contributor

@GEOFBOT GEOFBOT commented Apr 30, 2017

#467

Example usage:
utils.getEmojiUrl('🐍', 128) returns https://static.xx.fbcdn.net/images/emoji.php/v8/ze1/1.5/128/1f40d.png which is the emoji asset url for the snake emoji:

🐍

@ravkr
Copy link
Contributor

ravkr commented Apr 30, 2017

I think this should be in a separate file and added to https://github.com/Schmavery/facebook-chat-api/blob/master/index.js#L75
(and also to DOCS)

@Schmavery
Copy link
Owner

@ravkr is right, if this function is meant for general users (not just internally), then it should be exposed in that way. Let me know if you need help with that.
Is this a feature that anyone thinks they would use? Trying to understand the usecase.

@GEOFBOT
Copy link
Contributor Author

GEOFBOT commented May 1, 2017

@Schmavery My rationale was that if someone wanted to render the messages obtained using this API, they might want to use the same emojis that Messenger uses. I was working on a Messenger log export tool (GEOFBOT/flexr if anyone's interested) using this library and I wanted to use Messenger-style emojis in the output, so I figured out this function.

@Schmavery
Copy link
Owner

Ok, seems reasonable. Feel free to add a link to your tool to the end of the README (in a separate PR) when it's ready 😄

@GEOFBOT
Copy link
Contributor Author

GEOFBOT commented May 15, 2017

Question: getEmojiUrl doesn't require the user to be logged in, but adding it to index.js would require the user to log in before they can use the function. Is that OK?

@Schmavery
Copy link
Owner

Can we assume for now that everyone using the api is logging in using it? I think I'd rather go with that for now.

@GEOFBOT
Copy link
Contributor Author

GEOFBOT commented Jun 6, 2017

Sorry for the delay; I've moved the function into its own file and added docs

const baseUrl = 'https://static.xx.fbcdn.net/images/emoji.php/v8/z%s/%s';
pixelRatio = pixelRatio || '1.0';

let ending = util.format('%s/%s/%s.png', pixelRatio, size, c.codePointAt(0).toString(16));
Copy link
Owner

@Schmavery Schmavery Jun 6, 2017

Choose a reason for hiding this comment

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

Does util not need to be 'require'd for this to work?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

For some reason it worked when I tested it, but I've added the proper require

@Schmavery Schmavery merged commit 6513d32 into Schmavery:master Jun 12, 2017
@Schmavery
Copy link
Owner

Schmavery commented Jun 12, 2017

Thanks @GEOFBOT :)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants