Data Sources Extension

Endpoint Path

PathDescription
/api/fresns/post/lists获取帖子[列表]
/api/fresns/post/follows获取帖子关注的[列表]
/api/fresns/post/nearbys获取帖子附近的[列表]
/api/fresns/post/detail获取帖子[单条]
  • 列表:根据插件关联使用表 plugin_usages > data_sources 的配置,主程序会将请求通过默认命令字传输给插件,由插件处理客户端请求并返回结果。
  • 单条:根据配置表键名 post_detail_service 的配置,主程序会将请求通过默认命令字传输给插件,由插件处理客户端请求并返回结果。

See Also

Usage:

Command Word: fresns_cmd_default

Parameters NameTypeRequiredDescription
typeStringrequired类型 postLists / postFollows / postNearbys / postDetail
headerObjectrequiredAPI 全局 header 参数
bodyObjectrequired对应 API 的 body 参数

Example:

$cmd = BasePluginConfig::FRESNS_CMD_DEFAULT;
$input = [
    'type'=> $type,
    'header'=> $request->header(),
    'body'=> $request->all(),
];
$resp =PluginRpcHelper::call(FresnsPlugin::class, $cmd, $input);
1
2
3
4
5
6
7
查看 header 示例
"header" => [
    "platform" => "1"
    "version" => "1.0.0"
    "versionInt" => "1"
    "appId" => "twfimi5csy0cbc5f"
    "sign" => "yYABkvUdj0eO9JGJnWySV2aT2li3i5d8JOzDeYkW9jesnrlt8CsHJUQB1tM1qCxz"
    "timestamp" => "1626608856"
    "langTag" => "zh-Hans"
    "timezone" => "+8"
    "uid" => "tch1msfe"
    "mid" => "5980111"
    "token" => "BZIrAbutwi6Aq23DF6bWDd3DC4AUFp"
    "cookie" => "Hm_lvt_6e28821385e5e7b327ae0b1058ff084e=1616122338; __gads=ID=c866b25e783ad49a-22a5be3780c600ce:T=1616151227:RT=1616151227:S=ALNI_MZ-npvoq_Rr6LfNy0i3sIYzdD3VnQ; _ga=GA1.2.1226548877.1616589676"
    "accept-encoding" => "gzip, deflate"
    "accept" => "*/*"
    "content-type" => "multipart/form-data; boundary=----WebKitFormBoundaryyeCT7ClMied2BIUX"
    "user-agent" => "fresns-extension"
    "content-length" => "467"
    "connection" => "keep-alive"
    "host" => "api.fresns.org"
]
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
查看 body 示例
"body" => [
    "searchType" => "video"
    "searchKey" => ""
    "searchMid" => "5980111"
    //与对应接口的传参一致,以此类推
]
1
2
3
4
5
6

Returns:

插件处理完毕并返回数据,主程序将直接把返回数据传输到主程序 API 接口。

  • 建议插件按照对应 API 的参数格式输出,保证不同客户端也能直接使用。
  • 如果你是自己定制的客户端,有特殊要求,那么插件也可以返回定制客户端要求的格式输出。