惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Vercel News
Vercel News
The GitHub Blog
The GitHub Blog
博客园 - 【当耐特】
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
Recent Announcements
Recent Announcements
D
Docker
GbyAI
GbyAI
酷 壳 – CoolShell
酷 壳 – CoolShell
WordPress大学
WordPress大学
The Cloudflare Blog
雷峰网
雷峰网
A
About on SuperTechFans
小众软件
小众软件
博客园 - Franky
博客园 - 聂微东
F
Full Disclosure
大猫的无限游戏
大猫的无限游戏
C
Check Point Blog
MongoDB | Blog
MongoDB | Blog
G
Google Developers Blog
Microsoft Azure Blog
Microsoft Azure Blog
U
Unit 42
freeCodeCamp Programming Tutorials: Python, JavaScript, Git & More
V
V2EX
Engineering at Meta
Engineering at Meta
宝玉的分享
宝玉的分享
aimingoo的专栏
aimingoo的专栏
量子位
P
Proofpoint News Feed
Hugging Face - Blog
Hugging Face - Blog
博客园_首页
罗磊的独立博客
Martin Fowler
Martin Fowler
D
DataBreaches.Net
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
S
Secure Thoughts
Project Zero
Project Zero
L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
C
Cybersecurity and Infrastructure Security Agency CISA
T
Tailwind CSS Blog
S
Schneier on Security
Blog — PlanetScale
Blog — PlanetScale
The Hacker News
The Hacker News
Spread Privacy
Spread Privacy
Security Latest
Security Latest
NISL@THU
NISL@THU
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
C
CXSECURITY Database RSS Feed - CXSecurity.com
J
Java Code Geeks

博客园 - 天心PHP

去除文件夹下面所有xlsx的样式脚本 php 上传视频到阿里云OSS (不用SDK) 升级版本 断点续传 php 上传视频到阿里云OSS (不用SDK) SHEIN 开放平台授权 mercadolibre 美卡多 拉取listing Amazon SP API批量更新价格 JSON_LISTINGS_FEED Ozon API接口 Wildberries API接口 沃尔玛拉取listing和库存 沃尔玛修改促销价格 Amazon SP API 拉取产品详情和修改产品属性 Amazon SP API拉取分类,五点,描述和关键字 Amazon SP API拉取日期范围报告和分类树 PHP 提取PDF文件内容 常用sql(1.分组取最新的 N 条数据; 2.删除重复数据 ) kaufland平台api mercadolibre 美卡多 本土授权(PKCE) go mod Amazon SP API拉取listing 和 批量调价
Allegro API接口
天心PHP · 2025-04-23 · via 博客园 - 天心PHP
<?php
class AllegroModel extends YbModel {

    protected $access_token = null;
    protected $client_id = null;
    protected $client_secret = null;
    protected $host_url = null;
    /**
     * db config key
     *
     * @return string
     */
    public function getDbKey() {
        return 'db';
    }

    public function __construct($account){
        $this->host_url = 'https://api.allegro.pl/';
        $this->access_token = $account['access_token'];
        $this->client_id = $account['client_id'];
        $this->client_secret = $account['client_secret'];
    }

    public function get_customer_returns($data)
    {
        foreach ($data as $key=>$val){
            $url.=$key.'='.$val.'&';
        }
        $params = rtrim($url,"&");
        $url = $this->host_url.'order/customer-returns';
        if($params){
            $url = $url.'?'.$params;
        }
        $headers[] = "Accept: application/vnd.allegro.beta.v1+json";
        $headers[] = "Authorization: Bearer " . $this->access_token;
        $headers[] = "Content-Type: application/vnd.allegro.beta.v1+json";
        $res = $this->cur_request($url, 'GET', '', $headers);
        return $res;
    }

    public function cur_request($URL, $type, $params, $headers)
    {
        $ch = curl_init();
        curl_setopt($ch, CURLOPT_URL, $URL);
        if ($headers != "") {
            curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
        } else {
            curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/x-www-form-urlencoded'));
        }
        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
        curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
        curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 30);
        switch ($type) {
            case "GET" :
                curl_setopt($ch, CURLOPT_HTTPGET, true);
                break;
            case "POST":
                curl_setopt($ch, CURLOPT_POST, true);
                curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
                break;
            case "PUT" :
                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
                curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
                break;
            case "PATCH":
                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'PATCH');
                curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
                break;
            case "DELETE":
                curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "DELETE");
                curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
                break;
        }
        $file_contents = curl_exec($ch);//获得返回值
        $responseCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);
        curl_close($ch);
        return [$responseCode, json_decode($file_contents, true)];
    }
}