| Current Path : /var/www/magento.test.indacotrentino.com/www/scripts/import/OLD/test/ |
| Current File : /var/www/magento.test.indacotrentino.com/www/scripts/import/OLD/test/testAuthentication1.php |
<?php
function sign($method, $url, $data, $consumerSecret, $tokenSecret)
{
$url = urlEncodeAsZend($url);
$data = urlEncodeAsZend(http_build_query($data, '', '&'));
$data = implode('&', [$method, $url, $data]);
$secret = implode('&', [$consumerSecret, $tokenSecret]);
return base64_encode(hash_hmac('sha256', $data, $secret, true));
}
function urlEncodeAsZend($value)
{
$encoded = rawurlencode($value);
$encoded = str_replace('%7E', '~', $encoded);
return $encoded;
}
// REPLACE WITH YOUR ACTUAL DATA OBTAINED WHILE CREATING NEW INTEGRATION
$consumerKey = '6fxozvw17jwgfeyqt48yjih4di3ssn0q';
$consumerSecret = 'xpcpn35eyi137089gfoliknjfl27qyp3';
$accessToken = '1s535lnh4zp9ujjhna5v2vewofuo10p6';
$accessTokenSecret = 'm5ab6997ciuhe9dfk6shls5ygr7dveqe';
$url = 'http://indaco2.38121.it/rest/V1/products/attributes';
$method = 'GET';
$consumerKey = '610dee75s27oe0jlx7dx8cyr5k275861';
$consumerSecret = 'aw0nis1v3kst9gxlozdewmf8pnotscxf';
$accessToken = '0kufmoncdszyzs13bkvyrkjxlgu593bj';
$accessTokenSecret = 'jvdbnuw6w4cfbv4o18cg44p400ap4ad6';
$url = 'http://magento.test.indacotrentino.com/rest/V1/modules';
//$url = 'http://magento.test.indaco.store/rest/V1/orders?searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B0%5D%5Bfield%5D=status&searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B0%5D%5Bvalue%5D=new%2Cprocessing%2Cpending_payment%2Cfraud%2Cpayment_review%2Cpending%2Cholded%2Cclosed%2Ccanceled%2Cpaypal_canceled_reversal%2Cpending_paypal%2Cpaypal_reversed&searchCriteria%5Bfilter_groups%5D%5B0%5D%5Bfilters%5D%5B0%5D%5Bcondition_type%5D=in&searchCriteria%5Bfilter_groups%5D%5B1%5D%5Bfilters%5D%5B0%5D%5Bfield%5D=state&searchCriteria%5Bfilter_groups%5D%5B1%5D%5Bfilters%5D%5B0%5D%5Bvalue%5D=new%2Cprocessing%2Cpending_payment&searchCriteria%5Bfilter_groups%5D%5B1%5D%5Bfilters%5D%5B0%5D%5Bcondition_type%5D=in';
//
$data = [
'oauth_consumer_key' => $consumerKey,
'oauth_nonce' => md5(uniqid(rand(), true)),
'oauth_signature_method' => 'HMAC-SHA256',
'oauth_timestamp' => time(),
'oauth_token' => $accessToken,
'oauth_version' => '1.0',
];
$data['oauth_signature'] = sign($method, $url, $data, $consumerSecret, $accessTokenSecret);
$curl = curl_init();
curl_setopt_array($curl, [
CURLOPT_RETURNTRANSFER => 1,
CURLOPT_URL => $url,
CURLOPT_HTTPHEADER => [
'Authorization: OAuth ' . http_build_query($data, '', ',')
]
]);
var_dump(curl_error($curl));
$result = curl_exec($curl);
curl_close($curl);
var_dump($result);