Home >PHP Framework >ThinkPHP >Example record: Problems using Topsdk\Topapi in ThinkPhp5.1

Example record: Problems using Topsdk\Topapi in ThinkPhp5.1

藏色散人
藏色散人forward
2022-11-13 16:31:061403browse

The followingthinkphp frameworkThe tutorial column will introduce to you the problems of using Topsdk\Topapi in ThinkPhp5.1. I hope it will be helpful to friends in need!

Remember that tp5.1 uses Topsdk\Topapi (to connect with Taobao open platform)

#1. The company has a project that needs to be connected to Taobao open platform. First, apply for an account, create an application and download it. Corresponding SDK;

Taobao will generate the corresponding api interface SDK according to the corresponding application permissions. You may need the ability of a certain interface, but there is no corresponding class in the SDK, so you must first apply for the corresponding interface permissions;

2. After downloading it directly (without using composer), it was not easy to put it in the vendor directory and use the vendor function to import it. Later, I found that the vendor function has been abandoned in tp5.1, and the loader class was not easy to use.

2.1 Direct download is as shown in the figure

Example record: Problems using Topsdk\Topapi in ThinkPhp5.1

#3. We want to automatically load and use the corresponding classes directly, and return to using the composer package; go to packagist.org / Search Topsdk\Topapi; find its package version v1.1

Add the Topsdk\Topapinq package to composer.json in the project (you can find a new tp5.1 for testing first) as shown in the figure

Example record: Problems using Topsdk\Topapi in ThinkPhp5.1

5. Open the command line and execute composer install or update

Create a controller test

Example record: Problems using Topsdk\Topapi in ThinkPhp5.1

7. Test ok Delete the package just downloaded by composer (it is only for basic capability classes), and copy the package originally downloaded in the application to the vendor directory.

8. During use, it may be reported that the xxx class cannot be found. Modify the file class name

Example record: Problems using Topsdk\Topapi in ThinkPhp5.1

9. Other pitfalls in the document examples may be related to The SDK code is inconsistent, you can modify it yourself

Recommended study: "thinkPHP Video Tutorial"

The above is the detailed content of Example record: Problems using TopsdkTopapi in ThinkPhp5.1. For more information, please follow other related articles on the PHP Chinese website!

Statement:
This article is reproduced at:learnku.com. If there is any infringement, please contact admin@php.cn delete