> For the complete documentation index, see [llms.txt](https://developers.oxylabs.io/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.oxylabs.io/products/cn/dai-li/residential-proxies/making-requests.md).

# 发起请求

#### **基础查询**

基础查询只需传入 `用户名` 和 `密码`。无需其他参数。此类查询会使请求从随机 IP 地址（代理）发出。每个新请求都会使用不同的代理。

#### 代码示例

在此示例中，向 `ip.oxylabs.io/location` 发起的请求来自随机 IP：

{% tabs %}
{% tab title="cURL" %}

```shell
curl -x pr.oxylabs.io:7777 -U "customer-USERNAME:PASSWORD" https://ip.oxylabs.io/location
```

{% endtab %}

{% tab title="PHP" %}

```php
<?php
$username = 'USERNAME';
$password = 'PASSWORD';
$proxy = 'pr.oxylabs.io:7777';
$query = curl_init('https://ip.oxylabs.io/location');
curl_setopt($query, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($query, CURLOPT_PROXY, "http://$proxy");
curl_setopt($query, CURLOPT_PROXYUSERPWD, "customer-$username:$password");
$output = curl_exec($query);
curl_close($query);
if ($output)
    echo $output;
?>
```

{% endtab %}

{% tab title="Python" %}

```python
import urllib.request
import random
username = 'USERNAME'
password = 'PASSWORD'
entry = ('http://customer-%s:%s@pr.oxylabs.io:7777' %
    (username, password))
query = urllib.request.ProxyHandler({
    'http': entry,
    'https': entry,
})
execute = urllib.request.build_opener(query)
print(execute.open('https://ip.oxylabs.io/location').read())
```

{% endtab %}

{% tab title="Java" %}

```java
package example;

import org.apache.http.HttpHost;
import org.apache.http.client.fluent.*;

public class Example {
    public static void main(String[] args) throws Exception {
        HttpHost entry = new HttpHost("pr.oxylabs.io", 7777);
        String query = Executor.newInstance()
            .auth(entry, "customer-USERNAME", "PASS")
            .execute(Request.Get("http://ip.oxylabs.io/location").viaProxy(entry))
            .returnContent().asString();
        System.out.println(query);
    }
}
```

{% endtab %}

{% tab title="C#" %}

```csharp
using System;
using System.Net;

class Example
{
    static void Main()
    {
        var client = new WebClient();
        client.Proxy = new WebProxy("pr.oxylabs.io:7777");
        client.Proxy.Credentials = new NetworkCredential("customer-USERNAME", "PASSWORD");
        Console.WriteLine(client.DownloadString("https://ip.oxylabs.io/location"));
    }
c
```

{% endtab %}

{% tab title="Ruby" %}

```ruby
require 'uri'
require 'net/http'

uri = URI.parse('https://ip.oxylabs.io/location')
proxy = Net::HTTP::Proxy('pr.oxylabs.io', 7777, 'customer-USERNAME', 'PASSWORD')

req = Net::HTTP::Get.new(uri.path)

result = proxy.start(uri.host,uri.port) do |http|
    http.request(req)
end

puts result.body
```

{% endtab %}
{% endtabs %}

单个 backconnect 代理（`pr.oxylabs.io:7777）`允许你通过用户名中的附加参数选择特定国家或城市的代理。此方式也支持会话控制。以下是凭据示例：

`customer-USERNAME-cc-US-city-CITY-sessid-abcde12345:PASSWORD`

`customer-USERNAME-cc-US-city-CITY-sessid-abcde12345-sesstime-5:PASSWORD`

下面是结构解析：

<figure><img src="/files/06aa645372a5247017d39443c62e2c96f77b98f1" alt=""><figcaption></figcaption></figure>

#### 查询参数

| 参数                                                          | 说明                                                                                                                                                                                                                                                                       |
| ----------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ |
| <mark style="background-color:green;">**`customer`**</mark> | 用户名                                                                                                                                                                                                                                                                      |
| `cc`                                                        | 不区分大小写的两字母国家代码 [**3166-1 alpha-2 格式**](https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2)。例如， `DE` 表示德国， `GB` 表示英国， `TH` 表示泰国。有关如何使用按国家/地区的代理的更多详情， [**这里**](/products/cn/dai-li/residential-proxies/location-settings/select-country.md).                                |
| `city`                                                      | 不区分大小写的英文城市名。该参数必须与 `cc` 为提高准确性，例如， `cc-GB-city-london` 用于英国伦敦； `cc-DE-city-berlin` 用于德国柏林。对于包含两个以上单词的城市，请将空格替换为 `_`， `city-st_petersburg` 或 `city-rio_de_janeiro`。点击 [**这里**](/products/cn/dai-li/residential-proxies/location-settings/select-city.md) 了解有关城市级定位的更多信息。 |
| `st`                                                        | 不区分大小写的美国州名，前缀为 us\_，例如， `us_california`, `us_illinois`. [**点击这里** ](/products/cn/dai-li/residential-proxies/location-settings/select-state.md)了解有关州级定位的更多信息。                                                                                                            |
| `sessid`                                                    | 用于保持后续查询使用同一 IP 的会话 ID。会话在 10 分钟后过期。之后，该会话 ID 将分配到新的 IP 地址。支持随机字符串、0-9 和 A-Z 字符。                                                                                                                                                                                         |
| `sesstime`                                                  | 会话时间参数会在一段时间内保持相同的 IP。最长会话时间为 30 分钟。                                                                                                                                                                                                                                     |
| <mark style="background-color:green;">**`密码`**</mark>       | 密码                                                                                                                                                                                                                                                                       |

&#x20;    \- 必填参数


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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://developers.oxylabs.io/products/cn/dai-li/residential-proxies/making-requests.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.
