Contact Us
Back top
Current Location : APIs > facebook
facebook Transactions( 82 )

facebook

Intro. : Facebook api

Tag : facebook On Shelves Time : 2016-11-08

Type :

文章 用户信息 评论

Tutorials

Total invocations(updated per hour)

Facebook 3.00 yuan/100calls Test Now

API Mark

Example

-- 请求示例 url 默认请求参数已经做URL编码 curl -i "https://api02.bitspaceman.com/post/facebook?apikey=你申请的apikey&uid=4"
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; import java.net.URL; import java.nio.charset.Charset; import org.json.JSONException; import org.json.JSONObject; import java.io.PrintWriter; import java.net.URLConnection; public class Example { private static String readAll(Reader rd) throws IOException { StringBuilder sb = new StringBuilder(); int cp; while ((cp = rd.read()) != -1) { sb.append((char) cp); } return sb.toString(); } public static JSONObject postRequestFromUrl(String url, String body) throws IOException, JSONException { URL realUrl = new URL(url); URLConnection conn = realUrl.openConnection(); conn.setDoOutput(true); conn.setDoInput(true); PrintWriter out = new PrintWriter(conn.getOutputStream()); out.print(body); out.flush(); InputStream instream = conn.getInputStream(); try { BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8"))); String jsonText = readAll(rd); JSONObject json = new JSONObject(jsonText); return json; } finally { instream.close(); } } public static JSONObject getRequestFromUrl(String url) throws IOException, JSONException { URL realUrl = new URL(url); URLConnection conn = realUrl.openConnection(); InputStream instream = conn.getInputStream(); try { BufferedReader rd = new BufferedReader(new InputStreamReader(instream, Charset.forName("UTF-8"))); String jsonText = readAll(rd); JSONObject json = new JSONObject(jsonText); return json; } finally { instream.close(); } } public static void main(String[] args) throws IOException, JSONException { // 请求示例 url 默认请求参数已经做URL编码 String url = "https://api02.bitspaceman.com/post/facebook?apikey=你申请的apikey&uid=4"; JSONObject json = getRequestFromUrl(url);; System.out.println(json.toString()); } }
//using System.Net.Security; //using System.Security.Cryptography.X509Certificates; private const String method = "GET"; static void Main(string[] args) { String bodys = ""; // 请求示例 url 默认请求参数已经做URL编码 String url = "https://api02.bitspaceman.com/post/facebook?apikey=你申请的apikey&uid=4"; HttpWebRequest httpRequest = null; HttpWebResponse httpResponse = null; if (url.Contains("https://")) { ServicePointManager.ServerCertificateValidationCallback = new RemoteCertificateValidationCallback(CheckValidationResult); httpRequest = (HttpWebRequest)WebRequest.CreateDefault(new Uri(url)); } else { httpRequest = (HttpWebRequest)WebRequest.Create(url); } httpRequest.Method = method; if (0 < bodys.Length) { byte[] data = Encoding.UTF8.GetBytes(bodys); using (Stream stream = httpRequest.GetRequestStream()) { stream.Write(data, 0, data.Length); } } try { httpResponse = (HttpWebResponse)httpRequest.GetResponse(); } catch (WebException ex) { httpResponse = (HttpWebResponse)ex.Response; } Console.WriteLine(httpResponse.StatusCode); Console.WriteLine(httpResponse.Method); Console.WriteLine(httpResponse.Headers); Stream st = httpResponse.GetResponseStream(); StreamReader reader = new StreamReader(st, Encoding.GetEncoding("utf-8")); Console.WriteLine(reader.ReadToEnd()); Console.WriteLine("\n"); } public static bool CheckValidationResult(object sender, X509Certificate certificate, X509Chain chain, SslPolicyErrors errors) { return true; }
<?php $method = "GET"; // 请求示例 url 默认请求参数已经做URL编码 $url = "https://api02.bitspaceman.com/post/facebook?apikey=你申请的apikey&uid=4"; $curl = curl_init(); curl_setopt($curl, CURLOPT_CUSTOMREQUEST, $method); curl_setopt($curl, CURLOPT_URL, $url); curl_setopt($curl, CURLOPT_FAILONERROR, false); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); curl_setopt($curl, CURLOPT_HEADER, true); curl_setopt($curl, CURLOPT_ENCODING, "gzip"); var_dump(curl_exec($curl)); ?>
# coding:utf-8 """ Compatible for python2.x and python3.x requirement: pip install requests """ from __future__ import print_function import requests # 请求示例 url 默认请求参数已经做URL编码 url = "https://api02.bitspaceman.com/post/facebook?apikey=你申请的apikey&uid=4" headers = { "Accept-Encoding": "gzip", "Connection": "close" } if __name__ == "__main__": r = requests.get(url, headers=headers) json_obj = r.json() print(json_obj)

Request Field( Params marked* means users should choose one from the each marked items to fill in.)

Property Name Type Mandatory Example Description
uid string * 4 获取该用户所发布的信息
pid string * 4_10103625699665601 获取该条文章的相关信息
pageToken string 翻页值,从API返回结果可以拿到
type string 获取相应post的点赞或分享列表数据

Response Fields

Property Name Type Example Description
  • hasNext boolean true false: 无下一页 true:有下一页
  • retcode string 000000 状态码(详见错误码表)
  • appCode string facebook 平台代号
  • dataType string post 数据类型
  • pageToken string enc_AdBhgxzOwy0fZBFjW6GXwbjJDRUca1SS5ccS 翻页值 用于获取下一页数据
  • -
    data array [...] 数据内容列表
    • posterId string 4 发布者id
    • commentCount number 76221 评论数
    • posterScreenName string Mark Zuckerberg 发布者昵称
    • url string https://www.facebook.com/4_10103685865597591 文章链接
    • imageUrls array [...] 图片列表
    • originUrl string https://www.facebook.com/zuck/videos/10103685865597591/ 被转发的链接
    • geoPoint string 37.484, -122.149 地理位置信息
    • mediaType string video 媒体类型
    • publishDate number 1493494203 发布日期时间戳
    • likeCount number 173477 点赞数
    • content string Part II of driving through South Bend, I 文章正文
    • parentPostId string 3791568f35f4c067d6403a5c344136cc 转发的原平台id
    • shareCount number 9506 分享数
    • parentAppCode string facebook 转发的原平台
    • publishDateStr string 2017-04-29T19:30:03 发布时间(UTC时间)
    • id string 4_10103685865597591 文章id
    • origin boolean false 是否原创
    • originContent string null 转发原文内容

Returns The Sample

{
    "hasNext": true,
    "retcode": "000000",
    "appCode": "facebook",
    "dataType": "post",
    "pageToken": "enc_AdBhgxzOwy0fZBFjW6GXwbjJDRUca1SS5ccSTKp4TvchMAF3De0qdfVEC8sZAcCQZCw1CtORi9eLls3iJvJJk8PlNIQ|1493425239",
    "data": [
        {
            "posterId": "4",
            "commentCount": 76221,
            "posterScreenName": "Mark Zuckerberg",
            "title": null,
            "url": "https:\/\/www.facebook.com\/4_10103685865597591",
            "imageUrls": [
                "https:\/\/fb-s-d-a.akamaihd.net\/h-ak-xtp1\/v\/t15.0-10\/s720x720\/18223192_10103685908017581_8465195272706719744_n.jpg?_nc_ad=z-m&oh=e0736750f4882bed329ad89749849443&oe=59C22C86&__gda__=1505738387_e11048d689aba9e12e3fef771eab44f5"
            ],
            "originUrl": "https:\/\/www.facebook.com\/zuck\/videos\/10103685865597591\/",
            "geoPoint": "37.484, -122.149",
            "mediaType": "video",
            "publishDate": 1493494203,
            "likeCount": 173477,
            "content": "Part II of driving through South Bend, Indiana with Mayor Pete Buttigieg.",
            "parentPostId": "3791568f35f4c067d6403a5c344136cc",
            "shareCount": 9506,
            "parentAppCode": "facebook",
            "publishDateStr": "2017-04-29T19:30:03",
            "id": "4_10103685865597591",
            "origin": false,
            "originContent": null
        }
    ]
}

Detailed Data

No Details

Error code

Error Return Value Format : JSON

{

message:"API rate limit exceeded",

retcode:100703

}
Error Code Error Message Detailed Description
100000 Server internal error 服务器内部错误
100001 Network error 网络错误
100002 Search no result 目标参数搜索没结果
100004 Target server error 目标服务器错误
100005 Param error 用户输入参数错误
100301 Account not found 用户帐号不存在
100700 Invalid authentication credentials 授权失败
100701 API stopped 您的当前API已停用
100702 Account stopped 您的账户已停用
100703 API rate limit exceeded 并发已达上限
100704 API maintenance API维护中
100705 API not found with these values API不存在
100706 Please add api first 请先添加api
100707 Number of calls exceeded 调用次数超限
100802 Missing url param 'time' or uri path is not equal to 2 请求路径错误或者缺少"time"参数
100803 Wrong pageToken 参数pageToken有误

Often With The Purchase Of Data