Subversion Repositories cheapmusic

Rev

Rev 96 | Rev 136 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 96 Rev 99
Line 20... Line 20...
20
// Get linkshare listings by advertiser id
20
// Get linkshare listings by advertiser id
21
function get_walmartCategory($config, $query, $searchCondition, $categoryId, $subCategories = []) {
21
function get_walmartCategory($config, $query, $searchCondition, $categoryId, $subCategories = []) {
22
    // API request variables
22
    // API request variables
23
    $numResults = $config['numResults'];
23
    $numResults = $config['numResults'];
24
 
24
 
-
 
25
    $result = getSearchCache("walmart", $query, $categoryId);
-
 
26
    if ($result === false) {
25
    // Construct the findItemsByKeywords HTTP GET call
27
        // Construct the findItemsByKeywords HTTP GET call
26
    $params = [];
28
        $params = [];
27
    $params["apiKey"] = $config["apiKey"];
29
        $params["apiKey"] = $config["apiKey"];
28
    $params["lsPublisherId"] = $config["publisherId"];
30
        $params["lsPublisherId"] = $config["publisherId"];
29
    $params["numItems"] = $numResults;
31
        $params["numItems"] = $numResults;
30
    $params["start"] = "1";
32
        $params["start"] = "1";
31
    $params["sort"] = "price";
33
        $params["sort"] = "price";
32
    $params["order"] = "asc";
34
        $params["order"] = "asc";
33
    $params["categoryId"] = $categoryId;
35
        $params["categoryId"] = $categoryId;
34
    $params["query"] = $query;
36
        $params["query"] = $query;
35
 
37
 
36
    $pairs = array();
38
        $pairs = array();
37
    foreach ($params as $key => $value) {
39
        foreach ($params as $key => $value) {
38
        array_push($pairs, rawurlencode($key)."=".rawurlencode($value));
40
            array_push($pairs, rawurlencode($key)."=".rawurlencode($value));
-
 
41
        }
-
 
42
        $canonical_query_string = join("&", $pairs);
-
 
43
 
-
 
44
        $url = "https://api.walmartlabs.com/v1/search?" . $canonical_query_string;
-
 
45
        $result = getUrl($url);
-
 
46
 
-
 
47
        saveSearchCache("walmart", $query, $categoryId, $result);
39
    }
48
    }
40
    $canonical_query_string = join("&", $pairs);
-
 
41
 
49
 
42
    $url = "https://api.walmartlabs.com/v1/search?" . $canonical_query_string;
-
 
43
    $result = getUrl($url);
-
 
44
    $result = utf8_encode($result);
50
    $result = utf8_encode($result);
45
    $result = json_decode($result);
51
    $result = json_decode($result);
46
 
52
 
47
    $arr = [];
53
    $arr = [];
48
 
54