Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

normalize 格式化url path方法会格式化openid,导致请求接口微信不能正确获取openid #69

Closed
yybawang opened this issue Dec 3, 2021 · 2 comments
Labels
question Further information is requested

Comments

@yybawang
Copy link

yybawang commented Dec 3, 2021

有的接口的path里是有 openid 的,openid 是有大小写的了,转换后就得到一个乱掉的openid了,

我请求的支付服务商->发放优惠券接口,微信会返回 PARAM_ERROR,appid和openid不匹配
如图

示例

@yybawang yybawang closed this as completed Dec 3, 2021
@TheNorthMemory TheNorthMemory added the question Further information is requested label Dec 3, 2021
@yybawang
Copy link
Author

yybawang commented Dec 3, 2021

感谢及时回复,大家有遇到类似的,可以查看 #56

@TheNorthMemory
Copy link
Collaborator

normalize 在还原URL的时候,具有大小写敏感特性,规则如下:

  1. 首字符大写是映射PHPinterface接口作用;
  2. 中间大写字符是映射连字符hyphen(-)作用;
  3. 首尾字符如果是下划线undersore(_),是还原uri_template作用;

例如,查询代金券详情,映射的PHP接口就形如:

<?php declare(strict_types=1);/* Generated file. DO NOT EDIT! */

namespace WeChatPay\OpenAPI\V3\Marketing\Favor\Users\_openid_\Coupons;

use Psr\Http\Message\ResponseInterface;
use GuzzleHttp\Promise\PromiseInterface;

/**
 * 这是一个纯接口描述文件,由程序自动生成,旨在为IDE提供结构提示,无他用。
 */
interface _coupon_id_
{
    /**
     * 查询代金券详情(同步模式)
     * @param array<string,mixed> $options
     * @link https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/marketing/convention/chapter3_6.shtml
     */
    public function get(array $options = [
        'openid' => '',
        'coupon_id' => '',
        'query' => [
            'appid' => '',
        ],
    ]): ResponseInterface;

    /**
     * 查询代金券详情(异步模式)
     * @param array<string,mixed> $options
     * @link https://pay.weixin.qq.com/wiki/doc/apiv3/wxpay/marketing/convention/chapter3_6.shtml#async
     */
    public function getAsync(array $options = [
        'openid' => '',
        'coupon_id' => '',
        'query' => [
            'appid' => '',
        ],
    ]): PromiseInterface;
}

上述文件符合Psr4规范,可正常反推出源URL的本来样子。

如果用PHPStorm,建议在开发环境再安装 iwechatpay/openapi 接口描述开发包,以上提示皆可自动提示完成。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants