All Projects → niltor → open-pdd-net-sdk

niltor / open-pdd-net-sdk

Licence: Apache-2.0 license
拼多多开放平台DotNet SDK

Programming Languages

C#
18002 projects

Projects that are alternatives of or similar to open-pdd-net-sdk

Cake
🍰 Cake (C# Make) is a cross platform build automation system.
Stars: ✭ 3,154 (+2271.43%)
Mutual labels:  nuget, dotnetcore
Quartznet
Quartz Enterprise Scheduler .NET
Stars: ✭ 4,825 (+3527.82%)
Mutual labels:  nuget, dotnetcore
Vortice.windows
.NET standard bindings for DirectX, WIC, Direct2D1, XInput, XAudio and X3DAudio
Stars: ✭ 427 (+221.05%)
Mutual labels:  nuget, dotnetcore
Dotnetcore
.NET 5 Nuget Packages.
Stars: ✭ 146 (+9.77%)
Mutual labels:  nuget, dotnetcore
Wpfdesigner
The WPF Designer from SharpDevelop
Stars: ✭ 479 (+260.15%)
Mutual labels:  nuget, dotnetcore
Bridge
♠️ C# to JavaScript compiler. Write modern mobile and web apps in C#. Run anywhere with Bridge.NET.
Stars: ✭ 2,216 (+1566.17%)
Mutual labels:  nuget, dotnetcore
aws-step-functions-plagiarism-demo-dotnetcore
A simple workflow for developing AWS Step Functions to demonstrate how you can combine AWS Step Functions with AWS Lambda using .NET 6 and the Serverless Application Model (SAM), and expose your workflow via an API Gateway!
Stars: ✭ 58 (-56.39%)
Mutual labels:  dotnetcore
Apache-IoTDB-Client-CSharp
C# client for Apache IoTDB
Stars: ✭ 36 (-72.93%)
Mutual labels:  nuget
Blazor.PersianDatePicker
A free JavaScript Jalali (Persian) and Gregorian (Miladi) dual datepicker library for Blazor applications
Stars: ✭ 40 (-69.92%)
Mutual labels:  nuget
Stock.Charts
This is a demo for use of the Skender.Stock.Indicators NuGet package. It is an Angular website with a .NET Web API for backend generation of indicators.
Stars: ✭ 42 (-68.42%)
Mutual labels:  dotnetcore
KuttSharp
🔪 .NET Package for kutt.it url shortener
Stars: ✭ 29 (-78.2%)
Mutual labels:  nuget
GAPITA
An anonymous and random chat messaging for talking to strangers! (Using SignalR C# and TypeScript)
Stars: ✭ 55 (-58.65%)
Mutual labels:  dotnetcore
background-workers-in-fsharp
A port of the Microsoft .NET Core Worker Service examples to F#
Stars: ✭ 23 (-82.71%)
Mutual labels:  dotnetcore
honeycomb
本项目用于验证一系列开源项目
Stars: ✭ 13 (-90.23%)
Mutual labels:  dotnetcore
MASA.Blazor
Blazor component library based on Material Design. Support Blazor Server and Blazor WebAssembly.
Stars: ✭ 469 (+252.63%)
Mutual labels:  dotnetcore
ViewFaceCore
C# 超简单的离线人脸识别库。( 基于 SeetaFace6 )
Stars: ✭ 345 (+159.4%)
Mutual labels:  nuget
IGeekFan.AspNetCore.Knife4jUI
support .NET Core3.0+,.NET Standard2.0 Swagger UI knife4j ui,you can use NSwagger or Swashbuckle.AspNetCore in packages
Stars: ✭ 178 (+33.83%)
Mutual labels:  nuget
ZetaProducerHtmlCompressor
A .NET port of Google’s HtmlCompressor library to minify HTML source code.
Stars: ✭ 31 (-76.69%)
Mutual labels:  nuget
eShopOnWeb
Sample ASP.NET Core 6.0 reference application, powered by Microsoft, demonstrating a layered application architecture with monolithic deployment model. Download the eBook PDF from docs folder.
Stars: ✭ 8,250 (+6103.01%)
Mutual labels:  dotnetcore
DotNetGraph
Create GraphViz DOT graph with .NET / C#
Stars: ✭ 57 (-57.14%)
Mutual labels:  dotnetcore

说明文档

Build status NuGet NuGet

open-pdd-net-sdk,拼多多开放平台 DotNet SDK。

特别说明

  • 遇到任何问题可通过底部联系方式反馈,作者会第一时间进行处理!
  • 2.2.0 版本开始,将提供多商户支持,同时将目标框架统一调整到.net5.0。
  • 2.3.0 提供消息服务支持,核心类库不再支持 .net framework.
  • 6.0 版本开始,目标框架统一调整到.net6.0

更新说明

更新文档已经迁移到CHANGELOG.md

类库说明

核心类库 MSDev.PddOpenSdk 支持基于 .net6.0 的项目,C#10.0。 控制台、客户端等类型项目可使用。

ASP.NET Core 项目请使用 Nuget 包 MSDev.PddOpenSdk.AspNetCore,可直接通过注入服务的方式使用。

Console项目

该项目是通过官方接口获取并自动生成所有请求模型类、返回模型类以及请求服务类,生成后部分类名会有重名,更改成不同的类名即可。

执行方法,打开Console目录,然后执行dotnet run命令即可。

执行成功后,可使用Visual Studio自带的代码清理,对所有文件进行代码格式化操作。

使用说明

PddOpenSdk 核心类库使用

适用于客户端、控制台等程序,Web应用请使用Nuget包 MSDev.PddOpenSdk.AspNetCore

支持 NET6.0 ,安装 Nuget 包 MSDev.PddOpenSdk

使用示例:

最新示例代码

using MSDev.PddOpenSdk;
using PddOpenSdk.Models.Request.Ddk;
using System.Text.Json;

// 替代下面配置信息
var client = new PddClient(new ClientConfig
{
    ClientId = "YourClientId",
    ClientSecret = "YourClientSecret",
    CallbackUrl = "YourCallbackUrl"
});

// 需要先拿到授权返回的code
var code = "";
// 使用code换取token
var token = await client.GetAccessTokenAsync(code);

if (token == null)
{
    Console.WriteLine(client.ErrorResponse.ErrorMsg);
}
else
{
    Console.WriteLine("token:"+ token.AccessToken); 
}
// 接口请求
var result = await client.DdkApi.GetDdkGoodsRecommendAsync(
    new GetDdkGoodsRecommend
    {
        CatId = 20100
    });

var response = result.GoodsBasicDetailResponse;
Console.WriteLine(JsonSerializer.Serialize(response));

ASP.NET Core 项目使用

先安装Nuget 包 MSDev.PddOpenSdk.AspNetCore

最新示例代码

  • 在 Startup.cs 中注入服务
services.Configure<PddOptions>(Configuration.GetSection("Pdd"));
services.AddPdd();
  • appsettings.json 配置项参考:
"Pdd": {
    "ClientId": "",
    "ClientSecret": "",
    "CallbackUrl": "",
    // 心跳间隔
    "HeartBeatSeconds": 5
}
  • 然后在控制器使用注入服务
readonly PddService _pdd;
public YourController(PddService pdd)
{
    _pdd = pdd;
}

在控制器中使用

/// <summary>
/// 测试获取token
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public async Task<IActionResult> Callback(string code)
{
    var token = await _pdd.GetAccessTokenAsync(code);
    return Content(token.AccessToken);
}

/// <summary>
/// 多租户测试
/// </summary>
/// <returns></returns>
public async Task<ActionResult> MultiTenantAsync()
{
    var service = new PddService(new PddOptions
    {
        ClientId = "",
        ClientSecret = "",
        CallbackUrl = "",
        // 也可直接将token
        // AccessToken=""

    });
    // 如果没有token,可通过该方法获取token
    await service.GetAccessTokenAsync(code: "");
    var result = await service.DdkApi.GetDdkGoodsRecommendAsync(
        new GetDdkGoodsRecommendRequestModel
        {
            CatId = 20100
        });
    return Json(result);
}
  • 图片上传示例
    var filePath = Path.Combine("images", "logo.png");
    byte[] bytes = System.IO.File.ReadAllBytes(filePath);

    // 构造图片上传内容
    string base64 = "data:image/png;base64," + Convert.ToBase64String(bytes);
    var model = new UploadGoodsImageRequestModel
    {
        Image = base64
    };
    var result = await _pdd.GoodsApi.UploadGoodsImageAsync(model)

使用socket消息订阅服务

  • StartUp.cs添加PddOption选项。
        // 获取选项
        services.Configure<PddOptions>(Configuration.GetSection("Pdd"));
  • 创建一个XXXHostService类,继承PddSocketHostServiceBase
  • 重写XXXHostServiceOnMessage方法,以进行消息的自定义处理。
  • Program.cs中添加启用服务的代码,如:
    public static IHostBuilder CreateHostBuilder(string[] args) =>
        Host.CreateDefaultBuilder(args)
            .ConfigureWebHostDefaults(webBuilder =>
            {
                webBuilder.UseStartup<Startup>();
            }).ConfigureServices(services =>
            {
                services.AddHostedService<XXXHostService>();
            });

XXXHostService 类可参考Sample项目。

  • 心跳检测间隔可在appsetting.json配置中进行配置,可参考Sample项目中的配置。 此外可在自定义的XXXHostService类中的构造方法中设置HeartBeartSeconds值,会覆盖配置中的值。

所有方法名与官方文档保持一致,并有中文注释提醒,只是更改了命名规范,非常容易查找使用。

已知问题

问题反馈

欢迎通过以下方式反馈问题:

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].