Files

copied

There are no circuits or boards in this repository.

Last update 5 years 4 months by Allan Chang
Files
src
tests
.gitignore
.travis.yml
README.md
composer.json
phpunit.xml
README.md

aliexapi

<![CDATA[]]>Build Status<![CDATA[]]> <![CDATA[]]>Latest Stable Version<![CDATA[]]> <![CDATA[]]>Total Downloads<![CDATA[]]> <![CDATA[]]>License<![CDATA[]]>

AliexApi is a PHP library for AliExpress Affiliate API program. You can use it to fetch product data. It interfaces with Aliexpress API functions such as listPromotionProduct, getPromotionProductDetail and getPromotionLinks. For more info on the API, visit <![CDATA[]]>http://portals.aliexpress.com/help/help_center_API.html<![CDATA[]]>. To see a working demo site, goto <![CDATA[]]>electronic gadgets<![CDATA[]]>.

This Library based on Jan Eichhorn's <![CDATA[]]>Amazon Product Advertising API<![CDATA[]]>.

If you like this package, feel free to <![CDATA[]]>buy me a coffee<![CDATA[]]> ☕️

AliExpress Affiliate Program

To signup and join the program, goto <![CDATA[]]>http://portals.aliexpress.com/<![CDATA[]]>, you need to apply for API Key to get access.

Installation

Composer

Add the package 'clchangnet/aliexapi' to composer.json file:

{ "require": { "clchangnet/aliexapi": "~1.0" } }

Update composer of the new package and download. Once done, you should see a folder 'clchangnet' under 'vendor' folder.

$ composer update $ composer install

This will update the autoloader file and the library would be found once you include it in your code.

Basic Usage:

Here is an example how to use Aliexpress API listPromotionProduct to search for products using keywords.

Search Products

Note: To search by category. uncomment 'categoryId' and comment 'keywords' in searchItems and listPromotionProduct

<?php

namespace App\Http\Controllers;

use Illuminate\Http\Request; use App\Http\Requests;

use AliexApi\Configuration\GenericConfiguration; use AliexApi\AliexIO; use AliexApi\Operations\ListProducts;

class AliapiController extends Controller { public function aliconfig($conf) { $conf ->setApiKey('ALIAPIKEY') ->setTrackingKey('ALITRACKINGID') ->setDigitalSign('ALIDIGITALSIGNATURE'); return $conf; }

public function index()
{
    $this-&gt;searchItems();
}

public function searchItems()
{
    $lppfields = [
        // 'categoryId' =&gt; '1501',
        'keywords' =&gt; 'baby shoes',
        ];
    $array = $this-&gt;listPromotionProduct($lppfields);
    dd($array);
}

public function listPromotionProduct($lppfields)
{
    $conf = new GenericConfiguration();
    $this-&gt;aliconfig($conf);
    $aliexIO = new AliexIO($conf);

    $listproducts = new ListProducts();
    $listproducts-&gt;setFields('productId,productTitle,productUrl,imageUrl');
    $listproducts-&gt;setKeywords($lppfields['keywords']);
    // $listproducts-&gt;setCategoryId($lppfields['categoryId']);
    $listproducts-&gt;setHighQualityItems('true');

    $formattedResponse = $aliexIO-&gt;runOperation($listproducts);
    $array = json_decode($formattedResponse, true);

    $array = array_merge($array, $lppfields);

    return $array;

}

}

public function getPromotionLinks() { $conf = new GenericConfiguration(); $this->aliconfig($conf); $aliexIO = new AliexIO($conf);

    $listproducts = new GetLinks();
    $listproducts-&gt;setFields('url,promotionUrl');
    $listproducts-&gt;setTrackingId('ALI_TRACKING_ID');
    $listproducts-&gt;setUrls('http://url1, http://url2');

    $formattedResponse = $aliexIO-&gt;runOperation($listproducts);
    $array = json_decode($formattedResponse, true);
    return $array;
}

Example Workflow: Use ListProducts to search using keywords and set what fields to return. Use GetLinksTo convert product urls to your affiliate link.

Webservice Documentation:

To find out about what fields can be return through API request, goto <![CDATA[]]>http://portals.aliexpress.com/help/help_center_API.html<![CDATA[]]>

Report a bug