Code Monkey home page Code Monkey logo

facebook-api-video-upload's Introduction

facebook-api-video-upload

Upload a video in chunk on the facebook api. more info

Install

$ npm i facebook-api-video-upload --save

Tested on OS X and Linux.

Usage

const fs = require('fs');
const fbUpload = require('facebook-api-video-upload');

const args = {
  token: "YOURTOKEN", // with the permission to upload
  id: "YOURID", //The id represent {page_id || group_id}
  stream: fs.createReadStream('./fixture.mp4'), //path to the video,
  title: "my video",
  description: "my description",
  thumb: {
    value: fs.createReadStream('./fixture.jpg'),
    options: {
      filename: 'fixture.jpg',
      contentType: 'image/jpg'
    }
  }
  // if you want the default thumb from the video just remove the field
  // you can add any extra fields from the api https://developers.facebook.com/docs/graph-api/reference/page/videos/#Creating
  // all keys except token, id, stream are passed to the final request
};

fbUpload(args).then((res) => {
  console.log('res: ', res);
  //res:  { success: true, video_id: '1838312909759132' }
}).catch((e) => {
  console.error(e);
});

Note

The Video API allows you to publish Videos on Pages and Groups. Publishing on Users is not supported. Read more

License

MIT © MrdotB

facebook-api-video-upload's People

Contributors

anon-exploiter avatar anorudes avatar dependabot[bot] avatar mrdotb avatar nderim1 avatar sansamour avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

facebook-api-video-upload's Issues

Uploading a video with a specific thumbnail

Currently using this node module to upload a video to facebook successfully, however we're struggling to see how we could go about setting a specific image as the video's thumbnail, any ideas?

Can you tell me how to perform Resumable upload using this module: )

const fs = require('fs');
const fbUpload = require('facebook-api-video-upload');

const args = {
token: "XXXXXXXXXXXXXXXXXX", // with the permission to upload
id: "XXXXXXXXXXXXX", //The id represent {page_id || group_id}
stream: fs.createReadStream('./video.mkv'), //path to the video,
title: "my video",
description: "my description",
thumb: {
value: fs.createReadStream('./video.jpg'),
options: {
filename: 'fixture.jpg',
contentType: 'image/jpg'
}
}
// if you want the default thumb from the video just remove the field
// you can add any extra fields from the api https://developers.facebook.com/docs/graph-api/reference/page/videos/#Creating
// all keys except token, id, stream are passed to the final request
};

fbUpload(args).then((res) => {
console.log('res: ', res);
//res: { success: true, video_id: '1838312909759132' }
// https://www.facebook.com/100080206917420/videos/1062597247944821/
}).catch((e) => {
console.error(e);
});

This example work fine in pc but when upload big files it failed bcz my server has low ram (512mb)
Im newbie :)

Type error when specifying if published or not

When specifying in the arguments if the post is published or not I get this error
TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string or Buffer. Received type boolean
How to specify a true or false preference?

Graph API version should be parameterized

Graph API version is hardcoded in the index.js file. It would be great if you could expose that as an argument to the function so that I can use the latest version of Graph API, i.e v7.0

deprecated?

Is this deprecated?

I keep getting a 100 error when sending a video, and from what i can tell i have the right api access, unless i've missed one

streamToPromise(...).then(...).spread is not a function

Using this in a production app and have recently started seeing this error

TypeError: streamToPromise(...).then(...).spread is not a function
1
at facebookApiVideoUpload (/var/app/current/node_modules/facebook-api-video-upload/index.js line 96 col 4)

[Feature request] Uploading on user's profile

Hi,

The script seems to work but can we make it to upload videos on user profiles as well?

Script error:
image

Permissions:
image

ErrorLog

{ StatusCodeError: 400 - {"error":{"message":"(#100) No permission to publish the video","type":"OAuthException","code":100,"fbtrace_id":""}}
    at new StatusCodeError (/home/umar_0x01/node_modules/request-promise/lib/errors.js:32:15)
    at Request.RP$callback [as _callback] (/home/umar_0x01/node_modules/request-promise/lib/rp.js:77:29)
    at Request.self.callback (/home/umar_0x01/node_modules/request/request.js:185:22)
    at Request.emit (events.js:198:13)
    at Request.<anonymous> (/home/umar_0x01/node_modules/request/request.js:1154:10)
    at Request.emit (events.js:198:13)
    at IncomingMessage.<anonymous> (/home/umar_0x01/node_modules/request/request.js:1076:12)
    at Object.onceWrapper (events.js:286:20)
    at IncomingMessage.emit (events.js:203:15)
    at endReadableNT (_stream_readable.js:1145:12)
    at process._tickCallback (internal/process/next_tick.js:63:19)
  name: 'StatusCodeError',
  statusCode: 400,
  message:
   '400 - {"error":{"message":"(#100) No permission to publish the video","type":"OAuthException","code":100,"fbtrace_id":""}}',
  error:
   { error:
      { message: '(#100) No permission to publish the video',
        type: 'OAuthException',
        code: 100,
        fbtrace_id: '' } },
  options:
   { method: 'POST',
     uri:
      'https://graph-video.facebook.com/v3.2/103097098504749/videos?access_token=...',

Thanks.

When is the video ready?

This wrapper does return successful when the video has been uploaded, however there is no way to see when the video has finished processing after upload. I did not expect it to help in this manner, as implementing this as suggested by Facebook involves registering web-hooks to your app and waiting for a callback from Facebook. However there seems to be a way to solve it without web-hooks, my idea revolves around the idea of checking the video-status field of the given video periodically to see if the status field equals "ready" signaling video being completely uploaded and processed.

https://developers.facebook.com/docs/graph-api/reference/video-status/

I will go about implementing this, but i really do wonder if anyone has any better ideas.

Anyway, great plugin makes video upload much less of a hassle.

Might update with my not so perfect solution to this, might decide to just go with the web-hook thing.

How to config private video

I want to configure public video blocking and set secret mode without knowing how to configure it. The config always returns an error. Can you help me with this .. thanks

when add

The first argument must be one of type string or Buffer. Received type boolean

    const args = {
        token: "TOKEN", // with the permission to upload
        id: "408178802639894", //The id represent {page_id || user_id || event_id || group_id}
        stream: fs.createReadStream(pathVideo), //path to the video,
        title: _name,
        description: _name,
        no_story: true,
        published:false
        // if you want the default thumb from the video just remove the field
        // you can add any extra fields from the api https://developers.facebook.com/docs/graph-api/reference/page/videos/#Creating
        // all keys except token, id, stream are passed to the final request
      };

ERROR==>

_http_outgoing.js:607
    throw new ERR_INVALID_ARG_TYPE('first argument',
    ^

TypeError [ERR_INVALID_ARG_TYPE]: The first argument must be one of type string or Buffer. Received type boolean

Usage?

Hi,

I installed the package with npm.. but even with usage in the readme I am still not sure how to actually "use" it. Is there any way you can expand on the details any for usage?

Access token

can you please suggest a guideline to generate tokens?

v1.2.0 exits with an error

I'm running the sample code for video upload with my own credentials, using the latest version (v1.2.0) but it exits with the following error:

node upload.js
/Users/kr/Documents/node_modules/facebook-api-video-upload/index.js:36
return rp(options).then(res => ({ ...res, id: video_id }));
^^^
SyntaxError: Unexpected token ...
at Object.exports.runInThisContext (vm.js:78:16)
at Module._compile (module.js:543:28)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object. (/Users/kr/Documents/biber/upload.js:2:18)
at Module._compile (module.js:571:32)

With version v1.1.1 it works just fine (but it doesn't return the video id after upload).

The following is my environment:
-OS: macos sierra
-node: v7.2.1
-npm: v3.10.9

Can not upload large size > 2GB

Dear Team,

I can not upload file large 2GB, It seems it is over max buffer size?

Unhandled rejection RangeError [ERR_INVALID_OPT_VALUE]: The value "2385986836" is invalid for option "size" at Function.allocUnsafe (buffer.js:275:3) at Function.concat (buffer.js:460:23) at concat (/var/upfb/node/node_modules/stream-to-promise/index.js:26:21) at <anonymous> at process._tickCallback (internal/process/next_tick.js:118:7)

How can I solve this problem? Thanks Team

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.