Created
December 13, 2022 22:25
-
-
Save iods/8c721fb7bcd420d031902806dbe45843 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
header("Content-type: application/json; charset=utf-8"); | |
header("Access-Control-Allow-Origin: *") | |
$magentoSiteUrl = 'http://www.YOUR-SITE.com'; | |
$userData = array("username" => 'A_ADMIN_USERNAME', "password" => 'A_ADMIN_PASSWORD'); | |
define('MAGENTO_SITE_URL',$magentoSiteUrl); | |
$ch = curl_init($magentoSiteUrl."/index.php/rest/V1/integration/admin/token"); | |
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); | |
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData)); | |
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); | |
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Lenght: " . strlen(json_encode($userData)))); | |
$token = curl_exec($ch); // get access Token, use it for API call | |
$jobName = $_REQUEST['jobname']; | |
switch ($jobName){ | |
case 'getproducts': | |
getProductsData($token); | |
break; | |
default: | |
echo "Not Job Name found in request"; | |
break; | |
} | |
function getProductsData($accToken) | |
{ | |
$searchCriteria=''; | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment