WIKI导航首页

流程:

相关下载:

各语言调用示例DEMO:

DLL函数原型说明:

关于我们

编辑

Linux

 Linux平台API.so文件下载:
 [2014.2.18][1.0.0].so文件:libUUWiseHelper.so.1.0.0版本  (Linux平台调用)
 如提示缺少依赖项,请下载QT  QT下载 

so库中的所有函数原型:

 extern "C" void  uu_setSoftInfoA(int nSoftID, const char* pcSoftKey);
 extern "C" int  uu_loginA(const char* pcUsername, const char* pcPassword);
 extern "C" int  uu_getScoreA(const char* pcUsername, const char* pcPassword);
 extern "C" int  uu_reguserA(const char* pcUsername, const char* pcPassword, int nSoftID, const char* pcSoftKey);
 extern "C" int  uu_payA(const char* username, const char* card, int nSoftID, const char* pcSoftKey);
 extern "C" int  uu_UploadFileA(const char* pcPicPath, int nCodeType);
 extern "C" void  uu_getResultA(int nCodeID, char* pCodeResult);
 extern "C" int  uu_reportError(int nCodeID);
 extern "C" int  uu_recognizeByCodeTypeAndPathA(const char* pcPicPath, int nCodeType, char* pCodeResult);
 extern "C" int  uu_recognizeByCodeTypeAndBytesA(const char* pPicBytes, int NumberOfBytes, int nCodeType, char* pCodeResult);
 extern "C" int uu_recognizeByCodeTypeAndUrlA(const char* pcUrl, const char* pcInCookie, int nCodeType, char* pCookieResult, char* pCodeResult);

以下为C++ Qt的的示例代码:

  1. include <QtCore/QCoreApplication>
  2. include <QSettings>
  3. include <QString>
  4. include <QDebug>
  5. include <QDir>
  6. include <QDateTime>
  7. include <QFile>
  8. include <QThread>
  9. include <sys/syscall.h>
  10. include <QTimer>
  11. include <QEventLoop>
  12. include <QNetworkAccessManager>
  13. include <QNetworkRequest>
  14. include <QNetworkReply>
  15. include <QNetworkInterface>
  16. include <dlfcn.h>
  17. include <stdio.h>
  typedef void (*uu_setSoftInfoA)(int, const char*); 
  typedef int (*uu_loginA)(const char*, const char*); 
  typedef int (*uu_reguserA)(const char* username, const char* password, int nSoftID, const char* pcSoftKey);
  typedef int (*uu_UploadFileA)(const char* pcPicPath, int nCodeType);
  typedef void (*uu_getResultA)(int, char*);
  typedef int (*uu_reportError)(int);
  typedef int (*uu_recognizeByCodeTypeAndPathA)(const char*, int, char*);
  typedef int (*uu_recognizeByCodeTypeAndUrlA)(const char* pcUrl, const char* pcInCookie, int nCodeType, char* pCookieResult, char* pCodeResult);

int main(int argc, char *argv[]) {

   QCoreApplication a(argc, argv);

   // dlopen 函数还会自动解析共享库中的依赖项。这样,如果您打开了一个依赖于其他共享库的对象,它就会自动加载它们。
   // 函数返回一个句柄,该句柄用于后续的 API 调用
   void *handle = dlopen("/home/temp/libUUWiseHelper.so.1.0.0", RTLD_LAZY);
   // 如果返回 NULL 句柄,表示无法找到对象文件,过程结束。否则的话,将会得到对象的一个句柄,可以进一步询问对象
   if(!handle)
   {
       printf("Open Error:%s.\n",dlerror());
       return 0;
   }

   //共享库中的函数原型
   uu_setSoftInfoA setSoftInfo;
   uu_loginA login;
   uu_loginA getScore;
   //使用 dlsym 函数,尝试解析新打开的对象文件中的符号。您将会得到一个有效的指向该符号的指针,或者是得到一个 NULL 并返回一个错误
   setSoftInfo = (uu_setSoftInfoA)dlsym(handle, "uu_setSoftInfoA");
   if(!setSoftInfo)
   {
       printf("Dlsym Error:%s.\n",dlerror());
       return 0;
   }
   setSoftInfo(94126, "234a4269ca324d6189e915bd85c040b1");

   login = (uu_loginA)dlsym(handle, "uu_loginA");
   if(!login)
   {
       printf("Dlsym Error:%s.\n", dlerror());
       return 0;
   }
   int userId = login("用户名", "密码");

   getScore = (uu_loginA)dlsym(handle, "uu_getScoreA");
   if(!getScore)
   {
       printf("Dlsym Error:%s.\n", dlerror());
       return 0;
   }
   int score = getScore("用户名", "密码");

   uu_reguserA regUser;
   regUser = (uu_reguserA)dlsym(handle, "uu_reguserA");
   if(!regUser)
   {
       printf("Dlsym Error:%s.\n", dlerror());
       return 0;
   }
   int newUserID = regUser("用户名", "密码", 94126, "234a4269ca324d6189e915bd85c040b1");

   uu_reguserA pay;
   pay = (uu_reguserA)dlsym(handle, "uu_payA");
   if(!pay)
   {
       printf("Dlsym Error:%s.\n", dlerror());
       return 0;
   }
   int balance = pay("用户名", "卡号", 94126, "234a4269ca324d6189e915bd85c040b1");

   uu_UploadFileA uploadFile = (uu_UploadFileA)dlsym(handle, "uu_UploadFileA");
   if(!uploadFile)
   {
       printf("Dlsym Error:%s.\n", dlerror());
       return 0;
   }
   int codeId = uploadFile("test.png", 1004);

   uu_getResultA getResult = (uu_getResultA)dlsym(handle, "uu_getResultA");
   if(!getResult)
   {
       printf("Dlsym Error:%s.\n", dlerror());
       return 0;
   }
   char codeResult[30];
   getResult(codeId, codeResult);

   uu_recognizeByCodeTypeAndPathA recPath = (uu_recognizeByCodeTypeAndPathA)dlsym(handle, "uu_recognizeByCodeTypeAndPathA");
   char codeResult[30];
   int codeId = recPath("tomcode.jpeg", 1004, codeResult);

      uu_reportError reportError = (uu_reportError)dlsym(handle, "uu_reportError");
      if(!reportError)
      {
          printf("Dlsym Error:%s.\n", dlerror());
          return 0;
      }
      int reportErrorResult = reportError(codeId);

   uu_recognizeByCodeTypeAndUrlA recUrl = (uu_recognizeByCodeTypeAndUrlA)dlsym(handle, "uu_recognizeByCodeTypeAndUrlA");
   char codeResult[30];
   int codeId = recUrl("http://captcha.qq.com/getimage?aid=1007901&r=0.6908243694130634", NULL, 1004, NULL, codeResult);
   // 调用 ELF 对象中的目标函数后,通过调用 dlclose 来关闭对它的访问
   dlclose(handle);
   qDebug() << userId;
   qDebug() << score;
   qDebug() << newUserID;
   qDebug() << balance;
   qDebug() << codeId;
   qDebug() << QString(codeResult);
   qDebug() << reportErrorResult;

   return a.exec();

}

 更新:
 1.0.0
    UU正式支持linux平台调用,提供.so库。