If I do the publishing with a curl command everything works correctly:
curl \
-F 'access_token=...' \
-F 'message=hello' \
https://graph.facebook.com/me/feed
And the response is:
{"id":"100001692713927_542460169153735"}
But doing the same from NodeJs making the POST using the request module:
var formData = {
access_token: '...',
message: 'hello5'
};
request.post('https://graph.facebook.com/me/feed', formData, function (error, response, body) { … });
I get the error:
{
"error": {
"message": "(#200) This API call requires a valid app_id.",
"type": "OAuthException",
"code": 200
}
}
I used both me and the user ID in the URL and the behavior is the same.
What can be wrong here?
The problem in the above code is the wrong format of the request.post data parameter. t should be:
var formData = {
form: {
access_token: "...",
message: "hello"
}
};
This was the mistake.
I think you will have to use Facebook SDK for Node.js, this might help you.
I think facebook POST request expects app_id -which is something you will get when you create an application at facebook over here - https://developers.facebook.com/apps .
That app_id when provided shall get you through.