我一直在尝试向 facebook 发送 HTTP POST 请求,但没有成功,我从服务器收到此响应:
HTTP/1.1 400 错误请求内容类型:text/html;charset=utf-8 日期:2016 年 12 月 10 日,星期六 21:28:17 GMT 连接:关闭 内容长度:2959
脸书 | 错误
抱歉,出了点问题,我们正在处理,会尽快修复
我的代码
#include <iostream>
#include <string.h>
#include <sys/types.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <stdlib.h>
#include <unistd.h>
#include <netdb.h>
#include <fstream>
using namespace std;
int main()
{
int s, error;
struct sockaddr_in addr;
s = socket(AF_INET, SOCK_STREAM, 0);
if(s <0)
{
cout<<"Error 01: creating socket failed!\n";
close(s);
return 1;
}
addr.sin_family = AF_INET;
addr.sin_port = htons(80);
inet_aton("31.13.90.36",&addr.sin_addr); …Run Code Online (Sandbox Code Playgroud)