tiktok / tiktok-business-api-sdk

An SDK built to facilitate application development to integrate with TikTok Business API.
https://ads.tiktok.com/marketing_api/docs?id=1764231376750658&rid=542rk6sm9jl
MIT License
88 stars 30 forks source link

Java : Maven / Gradle dependency not working #42

Open hmigneron opened 4 months ago

hmigneron commented 4 months ago

The documentation states that maven users should add this dependency to their POM file :

 <dependency>
   <groupId>io.swagger</groupId>
   <artifactId>business_api_client</artifactId>
   <version>1.0.0</version>
   <scope>compile</scope>
 </dependency>

or that gradle users should add the following dependency :

compile "io.swagger:business_api_client:1.0.0"

However, this doesn't resolve / the file doesn't exist at this address : https://repo.maven.apache.org/maven2/io/swagger/business_api_client/1.0.0/business_api_client-1.0.0.pom

More generally, the package name this is documented as using is io.swagger, which is not owned by Tiktok (and therefore sounds like a potential trademark issue if swagger were to do anything about it ?)

So, which dependency should we add to maven or gradle project to work with this library ?

rajdeepkhandelwal commented 1 month ago

Any update here i am also facing same issue

Initialising ReportingApi reportingApi = new ReportingApi(); Dependency

<dependency>
      <groupId>io.github.jasonchentt</groupId>
      <artifactId>tiktok-business-api-sdk-official</artifactId>
      <version>1.0.1</version>
    </dependency>

image

saivenkatmandava commented 4 weeks ago

Hi @hmigneron, In your case, if you are installing the SDK locally using git clone then use this:

   <dependency>
        <groupId>io.swagger</groupId>
        <artifactId>business_api_client</artifactId>
        <version>1.0.0</version>
        <scope>compile</scope>
    </dependency>

The import in code should be similar to

import io.swagger.client.api.ToolApi;

ToolApi apiInstance;

and inside the class:

apiInstance = new ToolApi();

and you can use apiInstance. toolLanguage to call the api. Hope this helps, moreover I would recommend to use the mvn library tiktok-business-api-sdk-official, and you can follow the example code in the readme.

saivenkatmandava commented 4 weeks ago

@hmigneron I think the issue is that, you might not have installed the SDK locally. Please follow the readme file to install it

saivenkatmandava commented 4 weeks ago

@rajdeepkhandelwal you can try to initialize in this way, this might solve your issue. first initialize as:

ToolApi apiInstance;

then assign the instance in the class:

apiInstance = new ToolApi();

Since you are using the mvn package:

you can refer to:


import io.swagger.client.api.ToolApi;
 import business_api.Response;;

 public class ToolTest {

   public static void main(String[] args) {
     ToolApi apiInstance = new ToolApi();
     String accessToken = "Your_accessToken_id";
     String advertiserId = "Your_advertiser_id";

     try {
         Response result = apiInstance.toolLanguage(advertiserId, accessToken);
         System.out.println(result);
         System.out.println("Success ToolApi#toolLanguage");

     } catch (Exception e) {
         System.err.println("Exception when calling ToolApi#toolLanguage");
         e.printStackTrace();
     }
   }
 }
hmigneron commented 4 weeks ago

@saivenkatmandava : That doesn't really answer the more general question though : why is TikTok publishing packages under io.swagger when clearly they do not own that domain and have no business in that namespace ?

jasonchentt commented 1 week ago

@hmigneron Thanks for noting this issue. We plan to change the groupId in the future major release version. However, we temporarily will keep it to avoid break changes for other sdk users.