# 获取用户 openid

#### &#x20;请求URL

* `https://p.mbd.pub/openid`

#### 请求方式

* GET

#### 请求参数

| **参数名**     | **必选** | **类型** | **说明**                                  |
| ----------- | ------ | ------ | --------------------------------------- |
| target\_url | 是      | string | 自动跳转地址，例如 <https://example.com?pid=123> |
| app\_id     | 是      | string | 你的app\_id                               |

假如需要接收 `openid` 的 url 是：

`http://www.example.com/abc?uid=32`

则直接通过浏览器跳转该 `url` 即可：

`https://p.mbd.pub/openid?app_id=1234567890&target_url=http://www.example.com/abc?uid=32`

完成 `openid` 获取后，微信浏览器会自动跳转至：

`http://www.example.com/abc?uid=32&openid=*************`


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://doc.mbd.pub/api/huo-qu-yong-hu-openid.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
