> 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/proxies/mobile-proxies/making-requests.md).

# 发起请求

学习使用 Oxylabs 移动代理发起请求。掌握基本查询结构，并使用参数进行位置定向、城市选择和会话控制。

## 基本查询

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

### 代码示例

在此示例中，对 `ip.oxylabs.io` 从随机 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'
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 代理允许你通过用户名中的附加参数选择特定国家/地区的代理。此方式也支持会话控制。以下是凭据结构示例：

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

### 查询参数

| 参数                                                        | 描述                                                                                                                                                                                                                                                                        |
| --------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| <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/proxies/mobile-proxies/location-settings/country.md#country-specific-entry-nodes).          |
| `城市`                                                      | 不区分大小写的英文城市名。此参数必须与 `cc` 配合以提高准确性，例如， `cc-GB-city-london` 伦敦，英国使用； `cc-DE-city-berlin` 柏林，德国使用。对于包含两个以上单词的城市，将空格替换为 `_`，例如， `city-st_petersburg` 还是 `city-rio_de_janeiro`。点击 [**这里**](/products/cn/proxies/mobile-proxies/location-settings/select-city.md) 以了解更多城市级定位信息。 |
| `st`                                                      | 不区分大小写的美国州名，前缀为 us\_，例如， `us_california`, `us_illinois`. [**点击此处**](/products/cn/proxies/mobile-proxies/location-settings/select-state.md) 以了解更多州级定位信息。                                                                                                                   |
| `sessid`                                                  | 会话 ID，用于在后续查询中保持相同 IP。会话在 10 分钟后过期。之后，该会话 ID 会被分配新的 IP 地址。支持随机字符串、0-9 和 A-Z 字符。                                                                                                                                                                                           |
| `sesstime`                                                | 会话时间参数会在一定时间内保持相同 IP。最大会话时间为 30 分钟。                                                                                                                                                                                                                                       |
| <mark style="background-color:green;">**密码**</mark>       | 密码                                                                                                                                                                                                                                                                        |

\- 必填参数

## 中国入口节点

我们已在香港和北京地区配置入口节点，以便从中国获得更好的连接。请注意，这是一個 HTTPS 代理节点。所有用户名参数与常规入口节点相同。

我们正在修复其余集成，届时将支持 HTTPS 协议。

```
https://a81298871.com:8000 - 香港
```

<pre><code><strong>https://cnt9t1is.com:8000 - 北京
</strong></code></pre>

{% 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'
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 %}

如果你从中国连接我们的 Mobile 网络，且使用提供的入口节点仍有问题，请通过以下方式联系我们： [**support@oxylabs.io**](mailto:support@oxylabs.io)，我们会一起找到解决方案。


---

# 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, and the optional `goal` query parameter:

```
GET https://developers.oxylabs.io/products/cn/proxies/mobile-proxies/making-requests.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
