首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >Node.js HTTPS POST请求头

Node.js HTTPS POST请求头
EN

Stack Overflow用户
提问于 2011-09-18 20:28:01
回答 1查看 79.6K关注 0票数 22

我想使用Node.js将状态更新发布到Facebook组。看起来Node.js没有发送报头…

代码语言:javascript
复制
var https = require('https');

var options = {
    host: 'graph.facebook.com',
    port: 443,
    path: '/'+group_id+'/feed?access_token='+access_token,
    method: 'POST',
    headers: { 'message': text }
};

var req = https.request(options, function(res) {
    console.log("statusCode: ", res.statusCode);
    console.log("headers: ", res.headers);

    res.on('data', function(d) {
        process.stdout.write(d);
    });
});

req.end();

日志数据如下:

代码语言:javascript
复制
statusCode:  400
headers:  { 'cache-control': 'no-store',
  'content-type': 'text/javascript; charset=UTF-8',
  expires: 'Sat, 01 Jan 2000 00:00:00 GMT',
  p3p: 'CP="Facebook does not have a P3P policy. Learn why here: http://fb.me/p3p"',
  pragma: 'no-cache',
  'www-authenticate': 'OAuth "Facebook Platform" "invalid_request" "(#100) A post to a group must have at least a message or attachment"',
  'x-fb-rev': '443252',
  'set-cookie': [ 'datr=removed; expires=Tue, 17-Sep-2013 12:18:08 GMT; path=/; domain=.facebook.com; httponly' ],
  'x-fb-server': '10.62.5.40',
  connection: 'close',
  date: 'Sun, 18 Sep 2011 12:18:08 GMT',
  'content-length': '115' }
{"error":{"message":"(#100) A post to a group must have at least a message or attachment","type":"OAuthException"}}
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/7461495

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档