How to retrieve Facebook Messenger Code (the unique image id) programmatically - facebook-messenger

I am building an app that uses Facebook Messenger Platform, and want to make use of the Messenger Codes that look like this:
Currently, I am able to retrieve it from the chat interface manually, which is hidden at the bottom (the circular pattern), shown here:
However, I would like to get this programmatically, and there is nothing that I can find in the docs that suggest that this is possible. When retrieving the image, we can inspect the URL as such:
https://business.facebook.com/messenger_code/generate/?image_format=image%2Fpng&image_size=420&profile_id=profile_id_goes_here&ext=ext_not_sure_what_this_is&hash=a_hash
Note that I've removed any ids and what not from the above, but without any of these, the image will not generate. Notably, I need ext and hash to get it to work, both of which changes from page to page.
I am assuming that hash is some sort of hash of the a name or profile image or something, while ext is something else altogether. Is anyone familiar with how I could generate the URL?

The new messenger code API allows you to retrieve the code programmatically
https://developers.facebook.com/docs/messenger-platform/messenger-code
curl -X POST -H "Content-Type: application/json" -d '{
"type": "standard",
"image_size": 1000
}' "https://graph.facebook.com/v2.6/me/messenger_codes?access_token=<ACCESS_TOKEN>"

Related

How do get the result from REST website that returns only text?

I'm trying to use a REST web service from Geonames.org. When I try to manually put in the url with the parameters, it would only return the Country Code. I've tried to search for ways to implement it, but most of what I've seen return JSON text with multiple keys and data. I feel like the answer should be pretty simple, but I'm unsure.
I'm trying to use this for a React project I'm working on.
Here is an example of what the url returns
Just looked into the docs of that API, and it says if you want to receive JSON responses simply add JSON keyword to the endpoint. Like here for given endpoint you have:
http://api.geonames.org/countryCodeJSON?formatted=true&lat=47.03&lng=10.2&username=demo
so just change countryCode to countryCodeJSON.
Source: http://www.geonames.org/export/JSON-webservices.html

send all messages to a specific channel in discord js

I started coding my discord bot, and have just tried adding a feature that logs specific raw events to a specific channel. I looked countless times on Reddit and this site to try and find a way that isn't deprecated, but no luck. I was hoping that I would answer on this website. To summarize, I need to send messages to a specific channel. Another thing is pulling information from things inside JSON files that look like this:
info.json: {t: 'PRESCENCE_UPDATE,
{other_thing_i_want_to_get: 'blah blah blah'}}
how do I get the other thing with a format of info.t.other_thing_i_want_to_get, or something like that?
i would recommend creating a json file and importing it.
using the npm module fs you can create WriteFileStreams to change the values stored in the file
const info = require('./path_to_json/info.json');
your json will have to look like:
{t: 'PRESCENCE_UPDATE', other_thing_i_want_to_get: 'blah blah blah'}
with this code you can get it using info.other_thing_i_want_to_get

Clean the URL like of Google+

Sorry for so brief title. I am wondering how Google+ makes user URLs so clean. I mean like :
https://plus.google.com/+PuruVijay
Would take me to my page. I want to know how is that + after/ was put and how it loaded the corresponding page. I want a database to get the URL. The URL actually should have been like
Plus.Google. com/user?id=134566
Looking for a good answer please help
Edit:
An example is of this page's URL
You can also do like that... just you need to create folder of name
e.g. http://yoursite.com/PuruVijay
here PuruVijay is folder you need to create in you Website directory.. and put index file in that folder
In a comment you say you are using an Apache server. The typical way to handle URL manipulations like this is the module mod_rewrite, which you can find documentation on here. This uses regular expressions to match URLs and direct to another. For example, a rule for /~user to /u/user is
RewriteRule ^/~([^/]+)/?(.*) /u/$1/$2
For the Google+ example, you say you want to translate from /+PuruVijay to /user?id=134566. This will be a little more complicated because the URL as given does not include the User ID, so you will have to retrieve the number some other way. You can however use mod_rewrite to redirect to /user?name=+PuruVijay. This would look something like (not tested!)
RewriteRule ^/\+(.*) /user?id=$1
Then, your user page can get the id parameter and look it up in the database to display the correct page, while allowing the user to type in an easy-to-remember URL.
As far as mapping PuruVijay to 134566, Google+ requires the custom URLs to be unique, so there is a 1-1 correspondence between the handle PuruVijay and the user ID number 134566. Otherwise it would be impossible to look up a specific ID number given a custom URL. Your site would have to place a similar restriction if you decide to allow custom handles like this.

Spring Roo & JSON: Define array based operations for delete, update,

I implemented a webservice with roo. All queries run fine.
Delete:
I miss a automatic generated method to delete multiple id/version pairs at once. A call could look like this:
curl -i -X DELETE -H Content-Type:application/json -d [{"id":1,"version":0},{"id":2,"version":0}] http://.../objects
Update:
I also miss an update method for many entries. Call could look the same as above but with the fields to update added and "-X PUT".
curl -i -X PUT -H Content-Type:application/json
-d [{"id":1,"version":0,"value":"new1"},{"id":2,"version":0,"value":"new2"}] http://.../objects
Insert:
Is there a way to get the id's or the contents back after I inserted an new object with json?
When I define the "Accept:application/json" header I get an empty response.
I rather want roo to update this methods then write my own, since there are many fields I would have to maintain. Otherwise roo would be useless.
Are there any templates I could adopt for my needs?
Thank you!
I am not quite sure what you are asking, but you can absolutely do normal REST methods using JSON. As for retrieving JSON, you can do that too. There is an annotation, I believe its #ResponseBody, that you tack on the front of your MVC method to tell Spring "my response will contain plain-text, not instructions on which template to return", then you just use the JSON methods on the Entities to output JSON.

Receive multi file post with google app engine

I want to receive multi file post from image uploader.(i use this)
Most examples show how to receive one image from post.
I tried many ways but never got the results.
For example
self.request.POST['Filename']
gives only first filename.
What to do when there are multiple files/images in post?
The reason for this is to resize before upload images, that are too big for google app engine
to upload.
EDIT:
self.request.POST.multi.__dict__
shows
{'_items':
[('Filename', 'camila1.jpg'),
('Filedata[]', FieldStorage('Filedata[]', 'camila1.jpg')),
('Upload', 'Submit Query\r\n--negpwjpcenudkacqrxpleuuubfqqftwm----negpwjpcenudkacqrxpleuuubfqqftwm\r\nContent-Disposition: form-data; name="Filename"\r\n\r\nbornToBeWild1.jpg'),
('Filedata[]', FieldStorage('Filedata[]', 'bornToBeWild1.jpg')),
('Upload', 'Submit Query')]}
Your flash uploader is designed to work with PHP and sends multiple Filedata[] fields (php interprets this as an array for easy access)
So you need to iterate and get them all:
def post(self):
for file_data in self.request.POST.getall('Filedata[]'):
logging.info(file_data.filename)
data should be file_data.value
Are you using the Django libraries available to you? If so, check this out.
Call self.request.POST.getall('Filename') to get a list of FieldStorage objects; each one contains one file. You can access the file data with .value, the name with .name, and the mimetype with .type.
I have no idea how that multi uploader works, I have made one in the past however and I just added a number on the end of input field name, then hide it. Then add a new file input field to add another file. The reason for this is that they don't let you play around with input file fields to much because you could make it upload files they didn't want you uploading.
Using my conventions, in your example the 2 files in your example would be "Filename0" and "Filename1". You could also use firebug to see what it renaming the input file fields to.
Edit: I had a look, and it's using flash. So i have no idea how it works.

Resources