First argument must be a string or Buffer
NeXTs opened this issue · 2 comments
As mentioned in "Publishing a multi-photo story" section of FB docs there is published
parameter which is boolean.
While uploading image to facebook using buffer, this parameter may throw an error "First argument must be a string or Buffer"
This library missed this parameter for upload example
But if we set it as:
FB.api('me/photos', 'post', {
source: { value: photoBuffer, options: { contentType: 'image/jpeg' } },
caption: 'My vacation',
published: false // <------- here it is
}, function (res) {
if(!res || res.error) {
console.log(!res ? 'error occurred' : res.error);
return;
}
console.log('Post Id: ' + res.post_id);
});
"First argument must be a string or Buffer" error will occur.
It appears to be that boolean parameters aren't supported by form-data
To work out around this, just change it's value to 0
or 1
.
Maybe this case should be handled by library? Or at least add note about this in docs. It may save few hours to someone.
Try 'false' for now.
There is no such thing as a boolean as far as query parameters go. When you type false
in the Graph API Explorer you're not sending a boolean, you're sending the string 'false'
.
Per-parameter/method special cases are irrelevant. This library doesn't and shouldn't hardcode special cases for individual parameters or methods, this library just sends API calls to the Graph API, it doesn't hardcode knowledge about the graph api's methods.
However it does appear that Facebook's client API formats booleans as param=false
and param=true
so it's worth updating the code to format things as such.
please mention that somewhere on the first page below the upload example...