Use Node.js and Facebook Graph API to build this "annonymous to facebook" system.
Node.js
Facebook Graph API
-
create mysql database must same as DB in kaobei.js.
-
create mysql datatable to record post must same as FanPageEnglishName in kaobei.js:
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY dataId TEXT NOT NULL ip TEXT NOT NULL postId TEXT NOT NULL postTime TEXT NOT NULL
-
create mysql datatable to record report must same as ReportDT in kaobei.js:
id BIGINT UNSIGNED AUTO_INCREMENT PRIMARY KEY dataId TEXT NOT NULL ip TEXT NOT NULL fbUserId TEXT NOT NULL reportTime TEXT NOT NULL
-
Edit these three files
kaobei.js about-this-site.js functions.js 內的 shorturl
-
Install canvas
https://github.com/Automattic/node-canvas
-
Enter this project
-
npm install
-
forever start bin/www
You can also use my API.
Method: POST,
URL: http://kbss.ga:81/API/PNG,
Body: {
PNGMinWidth: 750, //圖片最小寬度
PNGMinHeight: 300, //圖片最小高度
PNGPadding: 20, //圖片 Padding
PNGBackgroundColor: "#000000", //背景顏色
PNGStringColor: "#FFFFFF", //文字顏色
MainString: "test", //中間位置的主要文字
SignString: "test", //右下角簽名文字
FontFamilyKey: "微軟正黑粗體", //字體請參考下面可使用的字體列表
MainStringFontSize: 70, //主要文字的大小px
SignStringFontSize: 30 //簽名文字的大小px
},
Response: {
HeadBase64: "Base64 編碼的圖片包含 data:image/png;base64,"
} | {
error: true,
message: "錯誤訊息"
}
Get can be used fonts in this API server.
Method: GET,
URL: http://kbss.ga:81/API/FONTS,
Response: {
Fonts: [
"微軟正黑粗體"
...
]
}
Post only message to facebook.
Method: POST
URL: /{fanpageid}/feed
Body: {
message: 訊息,
link: 預覽網址
}
Post photo to facebook.
Method: POST
URL: /{fanpageid}/photos
Body: {
message: 訊息,
url: 圖片網址
}
Use bitly API to get short url from long url.
Method: GET
URL: http://api.bit.ly/v3/shorten?longUrl={1}&login={2}&apikey={3}&format=json";
//1: 長網址
//2: bitly使用者名稱
//3: bitly API Key
Response: {
data: {
url: 短網址
...
}
...
}