Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/facebook/8.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js:如何访问FaceBook广告API_Facebook_Node.js - Fatal编程技术网

Node.js:如何访问FaceBook广告API

Node.js:如何访问FaceBook广告API,facebook,node.js,Facebook,Node.js,如何使用Node.js访问Facebook Ads API?与使用http.createClient访问Node中的任何其他API的方式相同 此示例基于代理,但可以调整为发出任何类型的请求 借来 见资料来源。 var http = require('http'); http.createServer(function(request, response) { var proxy = http.createClient(80, request.headers['host']) var p

如何使用Node.js访问Facebook Ads API?

与使用http.createClient访问Node中的任何其他API的方式相同

此示例基于代理,但可以调整为发出任何类型的请求

借来

见资料来源。
var http = require('http');

http.createServer(function(request, response) {
  var proxy = http.createClient(80, request.headers['host'])
  var proxy_request = proxy.request(request.method, request.url, request.headers);

  proxy_request.addListener('response', function (proxy_response) {
    proxy_response.addListener('data', function(chunk) {
      response.write(chunk, 'binary');
    });
    proxy_response.addListener('end', function() {
      response.end();
    });
    response.writeHead(proxy_response.statusCode, proxy_response.headers);
  });

  request.addListener('data', function(chunk) {
    proxy_request.write(chunk, 'binary');
  });
  request.addListener('end', function() {
    proxy_request.end();
  });
}).listen(8080);