You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
2.1 KiB
64 lines
2.1 KiB
using BBWY.Common.Http;
|
|
using BBWY.Server.Model.Db;
|
|
using com.alibaba.openapi.client;
|
|
using com.alibaba.openapi.client.policy;
|
|
using Jd.Api;
|
|
using Jd.Api.Request;
|
|
using Jd.Api.Response;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Linq;
|
|
using System;
|
|
using System.Linq;
|
|
|
|
namespace BBWY.Test
|
|
{
|
|
internal class Program
|
|
{
|
|
private static IJdClient GetJdClient(string appKey, string appSecret)
|
|
{
|
|
return new DefaultJdClient("https://api.jd.com/routerjson", appKey, appSecret);
|
|
}
|
|
|
|
static void Main(string[] args)
|
|
{
|
|
IServiceCollection serviceCollection = new ServiceCollection();
|
|
serviceCollection.AddHttpClient();
|
|
serviceCollection.AddSingleton<RestApiService>();
|
|
var serviceProvider = serviceCollection.BuildServiceProvider();
|
|
|
|
var restAPiService = serviceProvider.GetRequiredService<RestApiService>();
|
|
|
|
var appkey = "5338239";
|
|
var secrect = "CZkpbcxbZgh";
|
|
var token = "58c781eb-56a3-444c-b00a-4bd1e13cd12b";
|
|
|
|
var client = new SyncAPIClient(appkey, secrect, restAPiService);
|
|
RequestPolicy reqPolicy = new RequestPolicy();
|
|
reqPolicy.HttpMethod = "POST";
|
|
reqPolicy.NeedAuthorization = false;
|
|
reqPolicy.RequestSendTimestamp = false;
|
|
reqPolicy.UseHttps = false;
|
|
reqPolicy.UseSignture = true;
|
|
reqPolicy.AccessPrivateApi = false;
|
|
|
|
Request request = new Request();
|
|
APIId apiId = new APIId();
|
|
apiId.Name = "alibaba.product.simple.get";
|
|
apiId.NamespaceValue = "com.alibaba.product";
|
|
apiId.Version = 1;
|
|
request.ApiId = apiId;
|
|
|
|
request.AccessToken = token;
|
|
|
|
request.RequestEntity = new
|
|
{
|
|
webSite = "1688",
|
|
productID = 656558558036
|
|
};
|
|
|
|
var result = client.NewRequest(request, reqPolicy);
|
|
Console.WriteLine(result.ToString());
|
|
}
|
|
}
|
|
}
|
|
|