Etsy Api PHP 认证请求

问题描述

目前我想制作一个带有按钮的页面,该按钮将检索我在 ETSY 上的所有商店订单的列表。

我找到了完美的包裹 https://github.com/inakiabt/etsy-php 有了它,一旦我检索到访问令牌,我只需要做这样的事情

$api->findAllShopReceipts(array('params' => array('shop_id' => '__SELF__')))

但是我的 Xampp(我使用的是 win 10 x64)没有 OAuth (PHPinfo()) 所以我不得不使用这个包:https://github.com/Y0lk/oauth1-etsy

这是我的代码

类 EtsyController 扩展了 MasterController { const VIEWS = 'etsyapp';

private $client;

/**
 * Constructeur
 */
public function __construct()
{
    parent::__construct();
    
    $this->client = new Etsy([
        'identifier'            =>      '***********************','secret'                =>      '**********','scope'                 =>      'listings_r transactions_r','callback_uri'          =>      'http://**********.loc/etsyapp/next','access_token'          =>      $_SESSION['access_token'],'access_token_secret'   =>      $_SESSION['access_token_secret'],]);
}


/**
 * TEST AVEC PACKAGE Y0lk
 */
public function EtsyConnect()
{

    
    
    // On envoi une requête à l'API avec notre consumer & secrey key,et elle nous renvoi nos identifiants temporaires 
    $tempCred = $this->client->getTemporaryCredentials();

    // On store nos identifiants dans la Session
    $_SESSION['temporary_credentials'] = serialize($tempCred);

    $tmpSecret = $tempCred->getSecret();
    $tmpId = $tempCred->getIdentifier();
    
    // Avec nos infos on creer un lien vers une page d'autoriation de liaison de compte Etsy avec notre API
    $redirect_url = $this->client->getAuthorizationUrl($tempCred);
   
   return $this->render(self::VIEWS.'/home',[
        'redirect_url'  =>  $redirect_url,]);
}


/**
 * TEST AVEC PACKAGE Y0lk
 */
public function EtsyNext()
{
    
    if (isset($_GET['oauth_token']) && isset($_GET['oauth_verifier'])) {
        // Retrieve the temporary credentials we saved before
        $tempCred = unserialize($_SESSION['temporary_credentials']);
    
        // We will Now retrieve token credentials from the server
        $tokenCredentials = $this->client->getTokenCredentials($tempCred,$_GET['oauth_token'],$_GET['oauth_verifier']);
        
        // Je stock mes token en BDD (ou en SESSION,ou ailleurs...)
        $_SESSION['all_access_token'] = $tokenCredentials;
        $_SESSION['access_token'] = $tokenCredentials->getIdentifier();
        $_SESSION['access_token_secret'] = $tokenCredentials->getSecret();
    }

   return $this->render(self::VIEWS.'/next',[]);
}

}

我使用 EtsyConnect 来获取临时凭证,这允许我转到 etsy 登录/允许访问页面,并且在确认后,使用 URL 中的访问令牌回调我的 uri,在 EtsyNext 中我获得这些访问令牌,并存储它们在数据库中(为了我的测试,我只是将它们放在 SESSION 中)。 现在我的 $this->client = new Etsy 拥有所有令牌,这意味着我不必再次进入登录页面

但是从这里开始,我如何执行此请求:

enter image description here

我知道使用 inakiabt 包,我所要做的就是这样:

$api = new EtsyApi($this->client);
$api->findAllShopReceipts(array('params' => array('shop_id' => '__SELF__')));

但没有它我真的不知道。我什至试图用 curl 调用 url 但正常答案:This method requires authentication.

有人可以帮我做这个经过身份验证的请求吗?

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)