So I have made a couple of post requests to FB's API and they work fine, one of the POST actually spits out in the console the id of the user I'm supposed to pass if I want to get extra info about the profile in case I want to reuse it to post it somewhere else usign a different API.
So the idea is to get the user profile to reuse it.
Following the documentation: HERE
It's all good when done manually, because I get the info that I need by doing:
curl -X GET "https://graph.facebook.com/v2.6/<USER_ID>?fields=first_name,last_name,profile_pic,locale,timezone,gender&access_token=PAGE_ACCESS_TOKEN"
However if do in my code:
function getUserProfile (sender) {
request({
method : "GET",
uri : "https://graph.facebook.com/v2.6/" + sender + "?",
qs : {
fields:"first_name,last_name,profile_pic,locale,timezone,gender",
access_token : FB_PAGE_ACCESS_TOKEN
},
json : true
}
);
}
console.log('fb user GET Request: ', request);
I get a complaint about the uri not being passed correctly and I don't get nothing printed into console:
Here is the log:
> node app.js
fb user GET Request: function request(uri, options, callback) {
if (typeof uri === 'undefined') {
throw new Error('undefined is not a valid uri or options object.')
}
var params = initParams(uri, options, callback)
if (params.method === 'HEAD' && paramsHaveRequestBody(params)) {
throw new Error('HTTP HEAD requests MUST NOT include a request body.')
}
return new request.Request(params)
}
What am I missing? Any pointers would be great.
Edit:
I have found a SO post HERE and tried the solution given but the log is still invisible.
I am using heroku as server but I cannot see any objects from a GET request in the logs. I should be able to see what I'm getting, by console.log right?
These are the requires made:
const async = require("async");
const uuid = require("node-uuid");
const request = require('request');
const apiai = require('apiai');
const express = require('express');
const bodyParser = require('body-parser');
const JSONbig = require('json-bigint');