【问题标题】:Problems with making ebay REST api call进行 ebay REST api 调用的问题
【发布时间】:2017-03-29 11:58:50
【问题描述】:

我写了以下代码:

    include('httpful.phar');
include('config.php');
use \Httpful\Request;

class fullfil_pol_data{
    public $name='1dzien';
    public $marketplace='EBAY_PL';
    public $category=array('name' => 'ALL_EXCLUDING_MOTORS_VEHICLES');
    public $czas_wysylki=array('value'=> 1, 'unit'=>'DAY');
}
class aukcja{
    public $ilosc;
    public $cat_id;
    public $format;
    public $opis;
}
class token{
    public $token;
    private $duration;
    private $starts;
    public function __construct($t, $d){
        $this->token=$t;
        $this->duration=$d;
        $this->starts=time();
    }
    public function check(){
        if($this->duration+$this->starts >= time()-15*60) ibej::get_token();
    }
}
class ibej{
    private $token;
    private $sandbox=true;
    public function get_token()
    {
        if(this->sandbox) $url='https://api.sandbox.ebay.com/identity/v1/oauth2/token';
        $req= Request::post($url)->addHeader('Content-Type', 'application/x-www-form-urlencoded')
                                        ->addHeader('Authorization', 'Basic '.PASSES)
                                        ->body("grant_type=client_credentials&redirect_uri=Marketing_Desig-Marketin-wystaw-blzyg&scope=https://api.ebay.com/oauth/api_scope")->send();
        $this->token = new token($req->body->access_token, $req->body->expires_in);
        var_dump($this->token);
    }

    /*$url='https://api.sandbox.ebay.com/sell/inventory/v1/offer';
    //$req= Request::post($url)->addHeader('Authorization', 'Bearer '.$token)
        //                          ->addHeader('X-EBAY-C-MARKETPLACE-ID', 'EBAY-PL')
        */
    public function post_fullfilment_policy()
    {
        if(this->sandbox) $url='https://api.sandbox.ebay.com/sell/account/v1/fulfillment_policy';
        $test= new fullfil_pol_data;
        $req= Request::post($url)->addHeader('Authorization', 'Bearer '.$this->token->token)
                                ->addHeader('Accept', 'application/json')
                                ->addheader('Content-Type', 'application/json')
                                ->addHeader('X-EBAY-C-MARKETPLACE-ID', 'EBAY-US')
                                ->body(json_encode($test))->send();
        var_dump($req);
    }
}
$ibej_api = new ibej;
$ibej_api->get_token();
$ibej_api->post_fullfilment_policy();

当我尝试使用 ->post_fullfilment_policy() 方法调用 fullfilmentpolicy (http://developer.ebay.com/Devzone/rest/api-ref/account/fulfillment_policy__post.html) 时,我收到以下错误响应:

"{"errors":[{"errorId":1100,"domain":"ACCESS","category":"REQUEST","message":"Access denied","longMessage":"权限不足,无法完成请求。"}]}"

我不知道是什么问题,我认为如果我获得了令牌,它应该允许我使用我的帐户进行操作。谁能帮帮我?

【问题讨论】:

    标签: rest ebay-api


    【解决方案1】:

    您似乎创建了一个Application token。为了在 eBay 上执行涉及卖家账户的 API 操作,您必须创建一个用户令牌。documentation 对此进行了解释。请注意,获取用户令牌所涉及的过程要求用户登录到他们的 eBay 帐户以授予对您的应用程序的权限。该过程与获取应用程序令牌非常不同。

    【讨论】:

    • 一团糟!在我的 ebay 商店上发布商品的自主应用程序是不可能的!!!
    猜你喜欢
    • 1970-01-01
    • 2021-03-10
    • 2018-05-14
    • 2014-02-08
    • 1970-01-01
    • 2016-06-07
    • 2013-11-26
    • 2015-03-19
    • 1970-01-01
    相关资源
    最近更新 更多