marttype加载到word中不能用,Walmart Seller API POST无法正常工作,仅在PHP中提供未经授权的401...

I am trying to GET Walmart Seller API using CURL PHP to acknowledge.

Can any one suggest which RSA PHP library i need to use ? So that Authentication Signature is verify while making calls to walmart.

Any one experience with this ?

$headers = array(

'WM_SVC.NAME: Walmart Marketplace',

'WM_QOS.CORRELATION_ID: 14730688612',

'WM_SEC.TIMESTAMP:14730688612',

'WM_SEC.AUTH_SIGNATURE: XXXXXXXXXXX'

'WM_CONSUMER.ID: XXXXXXXXXXX',

'Content-Type: application/xml',

'Accept: application/xml',

);

$ch = curl_init();

curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);

curl_setopt($ch, CURLOPT_URL,$requestUrl);

curl_setopt($ch, CURLOPT_HEADER, TRUE);

curl_setopt($ch, CURLOPT_VERBOSE, true);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'GET');

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

$result = curl_exec( $ch );

if(curl_errno($ch)):

echo 'Curl error: '.curl_error($ch);

endif;

I have used reference that found while googling.

- https://github.com/fillup/walmart-auth-signature-php

解决方案

In the new API after August of 2018, you have to generate an access token AND then use a completely separate authentication header to pull anything from their API. It took a couple of hours just to figure this out, so I hope this helps someone in the future.

(This is for the Marketplace API, but should work for any Walmart API)

To generate the access token, you have to pass these headers:

Array(

[0] => Authorization: Basic BASE64_ENCODED_VARIABLE (see below)

[1] => Content-Type: application/x-www-form-urlencoded

[2] => Accept: application/json

[3] => WM_SVC.NAME: Walmart Marketplace

[4] => WM_QOS.CORRELATION_ID: 10_DIGIT_RANDOM_GENERATED_ALPHANUMERIC_ID

[5] => WM_SVC.VERSION: 1.0.0

[6] => WM_CONSUMER.CHANNEL.TYPE: PROVIDED_WHEN_GENERATING_CLIENT_ID_AND_SECRET

)

To generate BASE64_ENCODED_VARIABLE, create a variable using base64_encode as such:

$auth = base64_encode($clientId . ":" . $clientSecret);

...where Client ID and Client Secret are generated from Wal-Mart's Developer Portal API area.

===========================================

After you successfully POST that data to Walmart and receive an Access Token in return, you want to pass the following headers in ANY API CALL you make with Wal-Mart:

Array(

[0] => Authorization: Basic BASE64_ENCODED_VARIABLE (as described above)

[1] => WM_SVC.NAME: Walmart Marketplace

[2] => WM_QOS.CORRELATION_ID: 10_DIGIT_RANDOM_GENERATED_ALPHANUMERIC_ID

[3] => WM_CONSUMER.CHANNEL.TYPE: PROVIDED_WHEN_GENERATING_CLIENT_ID_AND_SECRET

[4] => WM_SEC.ACCESS_TOKEN: GENERATED_FROM_PREVIOUS_STEP (returned as [access_token])

[5] => Content-Type: application/json

[6] => Accept: application/json

)

...then make your calls.

This is what FINALLY worked for me after continuously receiving UNAUTHORIZED.GMP_GATEWAY_API errors across the board.

Passing "Authorization: Bearer TOKENTOKENTOKEN" instead of the way I've listed above WILL NOT WORK as the authentication header. Trust me :-)

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值