Get the Facebook User ID from a random profile URL - facebook

There are several solutions proposed, but as is stated here (https://stackoverflow.com/a/26839926/1893249 ) , it seems to be impossible.
In the FB Graph API explorer( https://developers.facebook.com/tools/explorer ), "/v2.4/cnn" returns the following, which is promising,
{
"name": "CNN",
"id": "5550296508"
}
until you put in "/v2.4/priscilla" and it returns:
{
"error": {
"message": "(#803) Cannot query users by their username (priscilla)",
"type": "OAuthException",
"code": 803
}
}
Likewise, this approach looks promising "/v2.4/?ids=http://www.imdb.com/title/tt0117500/"
until you put in "/v2.4/?ids=https://www.facebook.com/priscilla"
and it just returns the not-so-helpful:
{
"https://www.facebook.com/priscilla": {
"id": "https://www.facebook.com/priscilla"
}
}
But if it's impossible, than how is it done here?
http://findmyfbid.com/ with the URL,
https://www.facebook.com/priscilla

Scrapping the Facebook page Does the trick, but I'doubt if it's legal
curl -v https://www.facebook.com/USERNAME 2>&1 |
grep -o 'userID.*]' | head -n1 | cut -c 10-24

Related

How can I use Google Apps Script in Unity? [duplicate]

This question is about receiving POST request from somewhere. I'm looking for a google sheet script function that can take and handle data from the POST request in JSON format. Could you suggest any example?
The POST request is here:
https://script.google.com/macros/s/BOdirjv45Dn6FHrx_4GUguuS6NJxnSEeviMHm3HerJl4UsDBnDgfFPO/
{
"p1": "writeTitle",
"p2": [[URL]],
"p3": [[PIC_A]],
"p4": [[PIC_B]],
"p5": [[TITLE]]
}
application/json
doPost() doesn't work:
doPost(e) {
var json = JSON.parse(e.postData.contents);
Logger.log(json);
}
You want to retrieve the value from the request body as an object.
You have already deployed Web Apps.
If my understanding of your situation is correct, how about this modification?
Post and retrieved object:
As a sample, I used the following curl command to POST to Web Apps.
curl -L \
-H 'Content-Type:application/json' \
-d '{"p1": "writeTitle","p2": "[[URL]]","p3": "[[PIC_A]]","p4": "[[PIC_B]]","p5": "[[TITLE]]"}' \
"https://script.google.com/macros/s/#####/exec"
When above command is run, e of doPost(e) is as follows.
{
"parameter": {},
"contextPath": "",
"contentLength": 90,
"queryString": "",
"parameters": {},
"postData": {
"type": "application/json",
"length": 90,
"contents": "{\"p1\": \"writeTitle\",\"p2\": \"[[URL]]\",\"p3\": \"[[PIC_A]]\",\"p4\": \"[[PIC_B]]\",\"p5\": \"[[TITLE]]\"}",
"name": "postData"
}
}
The posted payload can be retrieved by e.postData. From above response, it is found that the value you want can be retrieved by e.postData.contents. By the way, when the query parameter and the payload are given like as follows,
curl -L \
-H 'Content-Type:application/json' \
-d '{"p1": "writeTitle","p2": "[[URL]]","p3": "[[PIC_A]]","p4": "[[PIC_B]]","p5": "[[TITLE]]"}' \
"https://script.google.com/macros/s/#####/exec?key=value"
value can be retrieved by e.parameter or e.parameters. And the payload can be retrieved by e.postData.contents.
Modified script:
In this modified script, the result can be seen at the Stackdriver, and also the result is returned.
function doPost(e) {
var json = JSON.parse(e.postData.contents);
console.log(json);
return ContentService.createTextOutput(JSON.stringify(json));
}
Note:
When you modified your script of Web Apps, please redeploy it as new version. By this, the latest script is reflected to Web Apps. This is an important point.
Reference:
Web Apps
Stackdriver Logging
If this was not what you want, I'm sorry.

Facebook Messenger API Messenge Attachments example does not work

I have a problem with reproducing the second example https://developers.facebook.com/docs/messenger-platform/reference/attachment-upload-api#example_request
It is:
curl \
-F 'message={"attachment":{"type":"image", "payload":{"is_reusable":true}}}' \
-F 'filedata=#/tmp/shirt.png;type=image/png' \
"https://graph.facebook.com/v6.0/me/message_attachments?access_token=<PAGE_ACCESS_TOKEN>"
When I check the request with httpbin, I get:
{
"args": {},
"data": "",
"files": {
"filedata": ""
},
"form": {
"message": "{\"attachment\":{\"type\":\"image\", \"payload\":{\"is_reusable\"=true}}}",
"recipient": "{\"id\":\"2673203139464950\"}"
},
"headers": {
"Accept": "*/*",
"Content-Length": "474",
"Content-Type": "multipart/form-data; boundary=------------------------855a2be7cb07aa99",
"Host": "httpbin.org",
"User-Agent": "curl/7.58.0",
"X-Amzn-Trace-Id": "Root=1-5e71f6ce-edeb373f3e446e443e23f2e3"
},
"json": null,
"origin": "my.ip.ad.dr",
"url": "https://httpbin.org/post"
}
When I run it locally, I get
{
"error":{
"message":"(#100) Field message must be a valid json object with string keys",
"type":"OAuthException",
"code":100,
"fbtrace_id":"ABYTTCTcFg7DoXr8i8ySdJB"
}
}
My attempts to solve it by myself are unsuccessful, despite several days of effort.
I guess, the problem is really simple, but I need help.
By the way, in general I need python-requests way of uploading files to Facebook, thus, if I had one, I would not need curl solution.
Any help will be appreciated.
I was told to replace the equals sign with a colon and add backslashes, however, it does not seem to work:
$ curl \
> -F 'message:{\"attachment\":{\"type\":\"image\", \"payload\":{\"is_reusable\": true}}}' \
> -F 'filedata=#/tmp/shirt.png;type=image/png' \
> "https://graph.facebook.com/v6.0/me/message_attachments?access_token=<MY-TOKEN>"
Warning: Illegally formatted input field!
curl: option -F: is badly used here
You only want to replace the second equal sign with a colon, the one after is_reusable, otherwise the JSON you provide is not valid. The equal sign after message should stay, because it is required by curl. Check out the documentation for more details.
In your case you want to use the following:
-F 'message={"attachment":{"type":"image","payload":{"is_reusable":true}}}'

how to setup “Get started” button in facebook messenger bot

I m trying to use postman
link:https://graph.facebook.com/v6.0/me/messages?access_token=my_token
{
"get_started":{
"payload": "Hi, I am bot"
}
}
in raw JSON body
but getting this response
{
"error": {
"message": "(#100) Tried accessing nonexisting field (messages) on node type (Page)",
"type": "OAuthException",
"code": 100,
"fbtrace_id": "AtFh2_fJ2sxkeU8k-2aNJGl"
}
}
Here is the little rundown how to put get started button , I hope its help:
Using postman:
Start by changing the type by choosing a POST request: (one of the
problems that solve my issue thanks to #misorude
Define a Post request to this URL:
https://graph.facebook.com/v6.0/me/messenger_profile?access_token=<PAGE_ACCESS_TOKEN>
As #misorude notice my another problem check endpoint from here https://developers.facebook.com/docs/messenger-platform/reference/messenger-profile-api
In the BODY section:
.
Paste this code:
{
"get_started":{
"payload": "Hi, I am bot"
}
}
P.S.
Thank you again

Cannot delete Facebook some test users

When I call:
$ curl 'https://graph.facebook.com/v2.2/<APP_ID>/accounts/test-users?access_token=<APP_ACCESS_TOKEN>&limit=500'
I see 82 accounts, and all but one look like this:
{
"id": "1413484435585065",
"login_url": "https://developers.facebook.com/checkpoint/test-user-login/1413484435585065/"
}
That is, they have no access token.
When I try to delete them I get:
$ curl -XDELETE 'https://graph.facebook.com/v2.2/1413484435585065?access_token=<APP_ACCESS_TOKEN>'
{
"error": {
"message": "(#100) Invalid value specified for param: id",
"type": "OAuthException",
"code": 100
}
}
The only one that DOES have an access token returns:
{
"error": {
"message": "(#2904) You cannot delete the Open Graph Test User for your app.",
"type": "OAuthException",
"code": 2904
}
}
If I go to Roles...Test Users on the Developers page of the app, then it is empty!
Any new test users I create I can see on the Developers page, and I can delete them using the mentioned curl call.
Where could these test users come from, and how do I get rid of them? Or at least filter them when I am listing test users.

FQL NoIndexFunctionException error 605 on an indexable column

I'm attempting:
SELECT developer_id FROM app_role WHERE application_id='MY APP ID'
Using a valid token, checked using https://developers.facebook.com/tools/explorer
I receive this back:
{
"error": {
"message": "Invalid application_id in WHERE clause",
"type": "NoIndexFunctionException",
"code": 604
}
}
Now. the application_id is definitely correct. The auth token is checked and associated with that app id, and as far as I can see application_id is totally indexable.
Any ideas what the grief is here? Thanks.
That's because you need an app access token. Get it this way:
GET https://graph.facebook.com/oauth/access_token?
client_id=YOUR_APP_ID
&client_secret=YOUR_APP_SECRET
&grant_type=client_credentials
Source: https://developers.facebook.com/docs/opengraph/howtos/publishing-with-app-token/
Then, use the same FQL request:
SELECT developer_id FROM app_role WHERE application_id='MY APP ID'
And there you go:
{
"data": [
{
"developer_id": "1234567890"
},
{
"developer_id": "9876543210"
}
]
}