Subversion Repositories cheapmusic

Rev

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

Rev 38 Rev 41
Line 240... Line 240...
240
        $refreshToken = $result->{'refresh_token'};
240
        $refreshToken = $result->{'refresh_token'};
241
        $tokenType =  $result->{'token_type'};
241
        $tokenType =  $result->{'token_type'};
242
    }
242
    }
243
 
243
 
244
    return $accessToken;
244
    return $accessToken;
-
 
245
}
-
 
246
 
-
 
247
// get linkshare coupon codes
-
 
248
function get_linkshareCoupons($config) {
-
 
249
    $vendors = Vendors::getInstance();
-
 
250
    $config = $vendors->getVendor(Vendors::LINKSHARE);
-
 
251
 
-
 
252
    $token = getLinkshareToken($config);
-
 
253
    if ($token === false) {
-
 
254
        return [];
-
 
255
    }
-
 
256
 
-
 
257
// Construct the findItemsByKeywords HTTP GET call
-
 
258
    $url = "https://api.rakutenmarketing.com/coupon/1.0?category=22&network=1&resultsperpage=100&pagenumber=1";
-
 
259
 
-
 
260
    $header = array(
-
 
261
        'Content-Type: application/x-www-form-urlencoded',
-
 
262
        'Accept: application/xml',
-
 
263
        'Accept-Language: en-US,en;q=0.5',
-
 
264
        'Accept-Charset: UTF-8,*;q=0.5',
-
 
265
        'Authorization: Bearer ' . $token
-
 
266
        );
-
 
267
 
-
 
268
    $ch = curl_init();
-
 
269
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
-
 
270
    curl_setopt($ch, CURLOPT_ENCODING, "gzip,deflate");
-
 
271
    curl_setopt($ch, CURLOPT_URL, $url);
-
 
272
    curl_setopt($ch, CURLOPT_AUTOREFERER, true);
-
 
273
    curl_setopt($ch, CURLOPT_HEADER, 0);
-
 
274
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
-
 
275
    $result = curl_exec ($ch);
-
 
276
 
-
 
277
	$result = utf8_encode($result);
-
 
278
	$result = simplexml_load_string($result);
-
 
279
 
-
 
280
    curl_close($ch);
-
 
281
 
-
 
282
//echo "$url<br><pre>";print_r($result);echo "</pre>";
-
 
283
 
-
 
284
	$arr = [];
-
 
285
 
-
 
286
// Check to see if the request found any results
-
 
287
	if (isset($result->TotalMatches)) {
-
 
288
  // If the response was loaded, parse it and store in array
-
 
289
		foreach ($result->item as $item) {
-
 
290
		}
-
 
291
	}
-
 
292
// If the response does not indicate 'Success,' log the error(s)
-
 
293
	else {
-
 
294
		foreach ($result->Errors as $error) {
-
 
295
		    if ($error->ErrorID != "7186919") { // no product found, not an error
-
 
296
    			error_log($url);
-
 
297
	    		error_log("$error->ErrorText ($error->ErrorId)");
-
 
298
	    	}
-
 
299
		}
-
 
300
	}
-
 
301
	
-
 
302
	return $arr;
245
}
303
}