{"id":818,"date":"2025-11-19T11:51:51","date_gmt":"2025-11-19T03:51:51","guid":{"rendered":"https:\/\/help.ipnut.com\/?post_type=docs&#038;p=818"},"modified":"2025-11-23T18:30:11","modified_gmt":"2025-11-23T10:30:11","password":"","slug":"php-integration-demo-ipnut-proxy-configuration-via-php","status":"publish","type":"docs","link":"https:\/\/www.ipnut.com\/help\/development-documentation\/php-integration-demo-ipnut-proxy-configuration-via-php\/","title":{"rendered":"PHP Integration Demo IPNut Proxy Configuration via PHP"},"content":{"rendered":"\t\t<div data-elementor-type=\"wp-post\" data-elementor-id=\"818\" class=\"elementor elementor-818\" data-elementor-post-type=\"docs\">\n\t\t\t\t<div class=\"elementor-element elementor-element-b92db2b e-flex e-con-boxed e-con e-parent\" data-id=\"b92db2b\" data-element_type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-f14bc85 elementor-widget elementor-widget-text-editor\" data-id=\"f14bc85\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p class=\"ds-markdown-paragraph\">After purchasing static IP services from IPNut platform, use the following PHP code samples for integration.<\/p><hr \/>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-8f5bb58 elementor-widget elementor-widget-heading\" data-id=\"8f5bb58\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h6 class=\"elementor-heading-title elementor-size-default\">1. SOCKS5 Proxy Implementation Socks5ProxyDemo.php<\/h6>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e122913 elementor-widget elementor-widget-code-highlight\" data-id=\"e122913\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-php \">\n\t\t\t\t<code readonly=\"true\" class=\"language-php\">\n\t\t\t\t\t<xmp><?php\r\n\/**\r\n * IPNut SOCKS5 Proxy Integration Demo\r\n *\/\r\n\r\nclass Socks5ProxyDemo {\r\n\r\n    private $proxy_host = 'proxy.ipnut.com';\r\n    private $proxy_port = 28001;\r\n    private $proxy_username = 'ipnut';\r\n    private $proxy_password = '123456789';\r\n\r\n    \/**\r\n     * SOCKS5 Proxy using cURL\r\n     *\/\r\n    public function socks5WithCurl() {\r\n        echo \"=== SOCKS5 Proxy with cURL ===\\n\";\r\n\r\n        $ch = curl_init();\r\n\r\n        try {\r\n            \/\/ Configure cURL with SOCKS5 proxy\r\n            curl_setopt_array($ch, [\r\n                CURLOPT_URL => 'https:\/\/httpbin.org\/ip',\r\n                CURLOPT_RETURNTRANSFER => true,\r\n                CURLOPT_TIMEOUT => 30,\r\n                CURLOPT_PROXY => $this->proxy_host . ':' . $this->proxy_port,\r\n                CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5,\r\n                CURLOPT_PROXYUSERPWD => $this->proxy_username . ':' . $this->proxy_password,\r\n                CURLOPT_USERAGENT => 'IPNut-PHP-SOCKS5\/1.0',\r\n                CURLOPT_SSL_VERIFYPEER => true,\r\n                CURLOPT_SSL_VERIFYHOST => 2\r\n            ]);\r\n\r\n            $response = curl_exec($ch);\r\n            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\r\n\r\n            if (curl_error($ch)) {\r\n                throw new Exception('cURL Error: ' . curl_error($ch));\r\n            }\r\n\r\n            echo \"Status Code: \" . $httpCode . \"\\n\";\r\n            echo \"Response: \" . $response . \"\\n\";\r\n            echo \"\u2705 SOCKS5 Proxy test completed successfully\\n\";\r\n\r\n        } catch (Exception $e) {\r\n            echo \"\u274c Request failed: \" . $e->getMessage() . \"\\n\";\r\n        } finally {\r\n            curl_close($ch);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Multiple requests through SOCKS5 proxy\r\n     *\/\r\n    public function socks5MultipleRequests() {\r\n        echo \"\\n=== SOCKS5 Multiple Requests ===\\n\";\r\n\r\n        $urls = [\r\n            'https:\/\/httpbin.org\/ip',\r\n            'https:\/\/httpbin.org\/user-agent',\r\n            'https:\/\/httpbin.org\/headers'\r\n        ];\r\n\r\n        foreach ($urls as $index => $url) {\r\n            echo \"\\nRequest \" . ($index + 1) . \": \" . $url . \"\\n\";\r\n\r\n            $ch = curl_init();\r\n            curl_setopt_array($ch, [\r\n                CURLOPT_URL => $url,\r\n                CURLOPT_RETURNTRANSFER => true,\r\n                CURLOPT_TIMEOUT => 30,\r\n                CURLOPT_PROXY => $this->proxy_host . ':' . $this->proxy_port,\r\n                CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5,\r\n                CURLOPT_PROXYUSERPWD => $this->proxy_username . ':' . $this->proxy_password,\r\n                CURLOPT_USERAGENT => 'IPNut-PHP-Multi\/1.0',\r\n                CURLOPT_SSL_VERIFYPEER => true\r\n            ]);\r\n\r\n            $response = curl_exec($ch);\r\n            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\r\n\r\n            if (curl_error($ch)) {\r\n                echo \"\u274c Request failed: \" . curl_error($ch) . \"\\n\";\r\n            } else {\r\n                echo \"\u2705 Status Code: \" . $httpCode . \"\\n\";\r\n                $data = json_decode($response, true);\r\n                echo \"Response Preview: \" . substr($response, 0, 120) . \"...\\n\";\r\n            }\r\n\r\n            curl_close($ch);\r\n            sleep(1); \/\/ Rate limiting\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * SOCKS5 Proxy with custom POST request\r\n     *\/\r\n    public function socks5CustomRequest() {\r\n        echo \"\\n=== SOCKS5 Custom POST Request ===\\n\";\r\n\r\n        $ch = curl_init();\r\n\r\n        try {\r\n            $headers = [\r\n                'User-Agent: IPNut-PHP-Custom\/1.0',\r\n                'Accept: application\/json',\r\n                'Content-Type: application\/json',\r\n                'X-Proxy-Type: SOCKS5'\r\n            ];\r\n\r\n            $postData = [\r\n                'service' => 'IPNut Proxy',\r\n                'protocol' => 'SOCKS5',\r\n                'timestamp' => date('c'),\r\n                'test_id' => uniqid()\r\n            ];\r\n\r\n            curl_setopt_array($ch, [\r\n                CURLOPT_URL => 'https:\/\/httpbin.org\/post',\r\n                CURLOPT_RETURNTRANSFER => true,\r\n                CURLOPT_TIMEOUT => 30,\r\n                CURLOPT_PROXY => $this->proxy_host . ':' . $this->proxy_port,\r\n                CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5,\r\n                CURLOPT_PROXYUSERPWD => $this->proxy_username . ':' . $this->proxy_password,\r\n                CURLOPT_POST => true,\r\n                CURLOPT_POSTFIELDS => json_encode($postData),\r\n                CURLOPT_HTTPHEADER => $headers,\r\n                CURLOPT_SSL_VERIFYPEER => true\r\n            ]);\r\n\r\n            $response = curl_exec($ch);\r\n            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\r\n\r\n            if (curl_error($ch)) {\r\n                throw new Exception('cURL Error: ' . curl_error($ch));\r\n            }\r\n\r\n            echo \"\u2705 Status Code: \" . $httpCode . \"\\n\";\r\n            $result = json_decode($response, true);\r\n            echo \"POST Response Data:\\n\";\r\n            print_r($result['json'] ?? $result);\r\n\r\n        } catch (Exception $e) {\r\n            echo \"\u274c POST request failed: \" . $e->getMessage() . \"\\n\";\r\n        } finally {\r\n            curl_close($ch);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Advanced SOCKS5 configuration with error handling\r\n     *\/\r\n    public function socks5Advanced() {\r\n        echo \"\\n=== SOCKS5 Advanced Configuration ===\\n\";\r\n\r\n        $ch = curl_init();\r\n\r\n        try {\r\n            curl_setopt_array($ch, [\r\n                CURLOPT_URL => 'https:\/\/httpbin.org\/anything',\r\n                CURLOPT_RETURNTRANSFER => true,\r\n                CURLOPT_TIMEOUT => 30,\r\n                CURLOPT_CONNECTTIMEOUT => 10,\r\n                CURLOPT_PROXY => $this->proxy_host . ':' . $this->proxy_port,\r\n                CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5,\r\n                CURLOPT_PROXYUSERPWD => $this->proxy_username . ':' . $this->proxy_password,\r\n                CURLOPT_USERAGENT => 'IPNut-Advanced-Client\/1.0',\r\n                CURLOPT_HTTPHEADER => [\r\n                    'Accept: application\/json',\r\n                    'X-Client: IPNut-PHP',\r\n                    'X-Request-ID: ' . uniqid()\r\n                ],\r\n                CURLOPT_SSL_VERIFYPEER => true,\r\n                CURLOPT_FOLLOWLOCATION => true,\r\n                CURLOPT_MAXREDIRS => 5\r\n            ]);\r\n\r\n            $response = curl_exec($ch);\r\n            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\r\n            $totalTime = curl_getinfo($ch, CURLINFO_TOTAL_TIME);\r\n\r\n            if (curl_error($ch)) {\r\n                throw new Exception('cURL Error: ' . curl_error($ch));\r\n            }\r\n\r\n            echo \"\u2705 Request completed successfully\\n\";\r\n            echo \"Status Code: \" . $httpCode . \"\\n\";\r\n            echo \"Total Time: \" . round($totalTime, 2) . \"s\\n\";\r\n            echo \"Response Size: \" . strlen($response) . \" bytes\\n\";\r\n\r\n        } catch (Exception $e) {\r\n            echo \"\u274c Advanced request failed: \" . $e->getMessage() . \"\\n\";\r\n        } finally {\r\n            curl_close($ch);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Run all SOCKS5 demonstrations\r\n     *\/\r\n    public function runAll() {\r\n        echo \"Starting IPNut SOCKS5 Proxy Tests...\\n\\n\";\r\n\r\n        $this->socks5WithCurl();\r\n        $this->socks5MultipleRequests();\r\n        $this->socks5CustomRequest();\r\n        $this->socks5Advanced();\r\n\r\n        echo \"\\n\u2705 All SOCKS5 proxy tests completed!\\n\";\r\n    }\r\n}\r\n\r\n\/\/ Run SOCKS5 demo if executed directly\r\nif (basename(__FILE__) == basename($_SERVER['PHP_SELF'])) {\r\n    $socks5Demo = new Socks5ProxyDemo();\r\n    $socks5Demo->runAll();\r\n}\r\n?><\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-92fc2f3 elementor-widget elementor-widget-heading\" data-id=\"92fc2f3\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h6 class=\"elementor-heading-title elementor-size-default\">2. HTTP Proxy Implementation\nHttpProxyDemo.php<\/h6>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-841b52a elementor-widget elementor-widget-code-highlight\" data-id=\"841b52a\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-php \">\n\t\t\t\t<code readonly=\"true\" class=\"language-php\">\n\t\t\t\t\t<xmp><?php\r\n\/**\r\n * IPNut HTTP Proxy Integration Demo\r\n *\/\r\n\r\nclass HttpProxyDemo {\r\n\r\n    private $proxy_host = 'proxy.ipnut.com';\r\n    private $proxy_port = 28001;\r\n    private $proxy_username = 'ipnut';\r\n    private $proxy_password = '123456789';\r\n\r\n    \/**\r\n     * HTTP Proxy using cURL\r\n     *\/\r\n    public function httpWithCurl() {\r\n        echo \"=== HTTP Proxy with cURL ===\\n\";\r\n\r\n        $ch = curl_init();\r\n\r\n        try {\r\n            curl_setopt_array($ch, [\r\n                CURLOPT_URL => 'https:\/\/httpbin.org\/ip',\r\n                CURLOPT_RETURNTRANSFER => true,\r\n                CURLOPT_TIMEOUT => 30,\r\n                CURLOPT_PROXY => $this->proxy_host . ':' . $this->proxy_port,\r\n                CURLOPT_PROXYTYPE => CURLPROXY_HTTP,\r\n                CURLOPT_PROXYAUTH => CURLAUTH_BASIC,\r\n                CURLOPT_PROXYUSERPWD => $this->proxy_username . ':' . $this->proxy_password,\r\n                CURLOPT_USERAGENT => 'IPNut-PHP-HTTP\/1.0',\r\n                CURLOPT_SSL_VERIFYPEER => true,\r\n                CURLOPT_SSL_VERIFYHOST => 2\r\n            ]);\r\n\r\n            $response = curl_exec($ch);\r\n            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\r\n\r\n            if (curl_error($ch)) {\r\n                throw new Exception('cURL Error: ' . curl_error($ch));\r\n            }\r\n\r\n            echo \"Status Code: \" . $httpCode . \"\\n\";\r\n            echo \"Response: \" . $response . \"\\n\";\r\n            echo \"\u2705 HTTP Proxy test completed successfully\\n\";\r\n\r\n        } catch (Exception $e) {\r\n            echo \"\u274c Request failed: \" . $e->getMessage() . \"\\n\";\r\n        } finally {\r\n            curl_close($ch);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * HTTP Proxy using stream context\r\n     *\/\r\n    public function httpWithStream() {\r\n        echo \"\\n=== HTTP Proxy with Stream Context ===\\n\";\r\n\r\n        try {\r\n            $context = stream_context_create([\r\n                'http' => [\r\n                    'proxy' => 'tcp:\/\/' . $this->proxy_host . ':' . $this->proxy_port,\r\n                    'request_fulluri' => true,\r\n                    'header' => [\r\n                        'Proxy-Authorization: Basic ' . base64_encode($this->proxy_username . ':' . $this->proxy_password),\r\n                        'User-Agent: IPNut-Stream-Client\/1.0',\r\n                        'Accept: application\/json'\r\n                    ],\r\n                    'timeout' => 30,\r\n                    'follow_location' => 1\r\n                ],\r\n                'ssl' => [\r\n                    'verify_peer' => true,\r\n                    'verify_peer_name' => true,\r\n                    'allow_self_signed' => false\r\n                ]\r\n            ]);\r\n\r\n            $response = file_get_contents('https:\/\/httpbin.org\/ip', false, $context);\r\n\r\n            if ($response === false) {\r\n                throw new Exception('Stream request failed');\r\n            }\r\n\r\n            $statusLine = $http_response_header[0] ?? '';\r\n            preg_match('\/HTTP\\\/\\d\\.\\d\\s+(\\d+)\/', $statusLine, $matches);\r\n            $httpCode = $matches[1] ?? 'Unknown';\r\n\r\n            echo \"\u2705 Status Code: \" . $httpCode . \"\\n\";\r\n            echo \"Response: \" . $response . \"\\n\";\r\n\r\n        } catch (Exception $e) {\r\n            echo \"\u274c Stream request failed: \" . $e->getMessage() . \"\\n\";\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * HTTP Proxy with concurrent requests\r\n     *\/\r\n    public function httpMultipleRequests() {\r\n        echo \"\\n=== HTTP Proxy Concurrent Requests ===\\n\";\r\n\r\n        $urls = [\r\n            'https:\/\/httpbin.org\/ip',\r\n            'https:\/\/httpbin.org\/user-agent',\r\n            'https:\/\/httpbin.org\/headers',\r\n            'https:\/\/httpbin.org\/get?test=ipnut_proxy'\r\n        ];\r\n\r\n        $multiHandle = curl_multi_init();\r\n        $handles = [];\r\n\r\n        foreach ($urls as $index => $url) {\r\n            $ch = curl_init();\r\n            curl_setopt_array($ch, [\r\n                CURLOPT_URL => $url,\r\n                CURLOPT_RETURNTRANSFER => true,\r\n                CURLOPT_TIMEOUT => 30,\r\n                CURLOPT_PROXY => $this->proxy_host . ':' . $this->proxy_port,\r\n                CURLOPT_PROXYTYPE => CURLPROXY_HTTP,\r\n                CURLOPT_PROXYUSERPWD => $this->proxy_username . ':' . $this->proxy_password,\r\n                CURLOPT_USERAGENT => 'IPNut-Concurrent\/1.0',\r\n                CURLOPT_SSL_VERIFYPEER => true\r\n            ]);\r\n\r\n            curl_multi_add_handle($multiHandle, $ch);\r\n            $handles[$index] = ['ch' => $ch, 'url' => $url];\r\n        }\r\n\r\n        \/\/ Execute concurrent requests\r\n        $running = null;\r\n        do {\r\n            curl_multi_exec($multiHandle, $running);\r\n            curl_multi_select($multiHandle);\r\n        } while ($running > 0);\r\n\r\n        \/\/ Process results\r\n        foreach ($handles as $index => $handle) {\r\n            echo \"\\nRequest \" . ($index + 1) . \": \" . $handle['url'] . \"\\n\";\r\n\r\n            $response = curl_multi_getcontent($handle['ch']);\r\n            $httpCode = curl_getinfo($handle['ch'], CURLINFO_HTTP_CODE);\r\n\r\n            if (curl_error($handle['ch'])) {\r\n                echo \"\u274c Request failed: \" . curl_error($handle['ch']) . \"\\n\";\r\n            } else {\r\n                echo \"\u2705 Status Code: \" . $httpCode . \"\\n\";\r\n                echo \"Response Preview: \" . substr($response, 0, 100) . \"...\\n\";\r\n            }\r\n\r\n            curl_multi_remove_handle($multiHandle, $handle['ch']);\r\n            curl_close($handle['ch']);\r\n        }\r\n\r\n        curl_multi_close($multiHandle);\r\n    }\r\n\r\n    \/**\r\n     * HTTP Proxy POST with JSON data\r\n     *\/\r\n    public function httpPostRequest() {\r\n        echo \"\\n=== HTTP Proxy POST Request ===\\n\";\r\n\r\n        $ch = curl_init();\r\n\r\n        try {\r\n            $postData = [\r\n                'service' => 'IPNut HTTP Proxy',\r\n                'protocol' => 'HTTP',\r\n                'authentication' => 'basic',\r\n                'timestamp' => date('c'),\r\n                'test_data' => [\r\n                    'feature' => 'static_ip',\r\n                    'stability' => 'high',\r\n                    'anonymity' => 'enterprise'\r\n                ]\r\n            ];\r\n\r\n            $headers = [\r\n                'Content-Type: application\/json',\r\n                'User-Agent: IPNut-PHP-POST\/1.0',\r\n                'X-API-Version: 1.0'\r\n            ];\r\n\r\n            curl_setopt_array($ch, [\r\n                CURLOPT_URL => 'https:\/\/httpbin.org\/post',\r\n                CURLOPT_RETURNTRANSFER => true,\r\n                CURLOPT_TIMEOUT => 30,\r\n                CURLOPT_PROXY => $this->proxy_host . ':' . $this->proxy_port,\r\n                CURLOPT_PROXYTYPE => CURLPROXY_HTTP,\r\n                CURLOPT_PROXYUSERPWD => $this->proxy_username . ':' . $this->proxy_password,\r\n                CURLOPT_POST => true,\r\n                CURLOPT_POSTFIELDS => json_encode($postData),\r\n                CURLOPT_HTTPHEADER => $headers,\r\n                CURLOPT_SSL_VERIFYPEER => true\r\n            ]);\r\n\r\n            $response = curl_exec($ch);\r\n            $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\r\n\r\n            if (curl_error($ch)) {\r\n                throw new Exception('cURL Error: ' . curl_error($ch));\r\n            }\r\n\r\n            echo \"\u2705 Status Code: \" . $httpCode . \"\\n\";\r\n            $result = json_decode($response, true);\r\n            echo \"POST Response Summary:\\n\";\r\n            echo \"  - Headers Sent: \" . count($result['headers'] ?? []) . \"\\n\";\r\n            echo \"  - Data Received: \" . strlen($response) . \" bytes\\n\";\r\n            echo \"  - Origin IP: \" . ($result['origin'] ?? 'Unknown') . \"\\n\";\r\n\r\n        } catch (Exception $e) {\r\n            echo \"\u274c POST request failed: \" . $e->getMessage() . \"\\n\";\r\n        } finally {\r\n            curl_close($ch);\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Run all HTTP demonstrations\r\n     *\/\r\n    public function runAll() {\r\n        echo \"Starting IPNut HTTP Proxy Tests...\\n\\n\";\r\n\r\n        $this->httpWithCurl();\r\n        $this->httpWithStream();\r\n        $this->httpMultipleRequests();\r\n        $this->httpPostRequest();\r\n\r\n        echo \"\\n\u2705 All HTTP proxy tests completed!\\n\";\r\n    }\r\n}\r\n\r\n\/\/ Run HTTP demo if executed directly\r\nif (basename(__FILE__) == basename($_SERVER['PHP_SELF'])) {\r\n    $httpDemo = new HttpProxyDemo();\r\n    $httpDemo->runAll();\r\n}\r\n?><\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-05b6ed0 elementor-widget elementor-widget-heading\" data-id=\"05b6ed0\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h6 class=\"elementor-heading-title elementor-size-default\">3. Connectivity Testing Utility\nProxyTestTool.php<\/h6>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-9b3ef50 elementor-widget elementor-widget-code-highlight\" data-id=\"9b3ef50\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-php \">\n\t\t\t\t<code readonly=\"true\" class=\"language-php\">\n\t\t\t\t\t<xmp><?php\r\n\/**\r\n * IPNut Proxy Connectivity Testing Tool\r\n *\/\r\n\r\nclass ProxyTestTool {\r\n\r\n    private $proxy_host = 'proxy.ipnut.com';\r\n    private $proxy_port = 28001;\r\n    private $proxy_username = 'ipnut';\r\n    private $proxy_password = '123456789';\r\n\r\n    \/**\r\n     * Test SOCKS5 proxy connectivity\r\n     *\/\r\n    public function testSocks5Proxy() {\r\n        echo \"Testing SOCKS5 Proxy Connectivity:\\n\";\r\n\r\n        $ch = curl_init();\r\n        curl_setopt_array($ch, [\r\n            CURLOPT_URL => 'https:\/\/httpbin.org\/ip',\r\n            CURLOPT_RETURNTRANSFER => true,\r\n            CURLOPT_TIMEOUT => 15,\r\n            CURLOPT_PROXY => $this->proxy_host . ':' . $this->proxy_port,\r\n            CURLOPT_PROXYTYPE => CURLPROXY_SOCKS5,\r\n            CURLOPT_PROXYUSERPWD => $this->proxy_username . ':' . $this->proxy_password,\r\n            CURLOPT_USERAGENT => 'IPNut-Test-Client\/1.0',\r\n            CURLOPT_SSL_VERIFYPEER => true\r\n        ]);\r\n\r\n        $response = curl_exec($ch);\r\n        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\r\n        $connectTime = curl_getinfo($ch, CURLINFO_CONNECT_TIME);\r\n\r\n        if (curl_error($ch)) {\r\n            echo \"\u274c SOCKS5 Proxy Connection Failed: \" . curl_error($ch) . \"\\n\";\r\n        } else {\r\n            echo \"\u2705 SOCKS5 Proxy Connection Successful\\n\";\r\n            echo \"   Status Code: \" . $httpCode . \"\\n\";\r\n            echo \"   Connect Time: \" . round($connectTime, 2) . \"s\\n\";\r\n            $data = json_decode($response, true);\r\n            echo \"   Assigned IP: \" . ($data['origin'] ?? 'Unknown') . \"\\n\";\r\n        }\r\n\r\n        curl_close($ch);\r\n    }\r\n\r\n    \/**\r\n     * Test HTTP proxy connectivity\r\n     *\/\r\n    public function testHttpProxy() {\r\n        echo \"\\nTesting HTTP Proxy Connectivity:\\n\";\r\n\r\n        $ch = curl_init();\r\n        curl_setopt_array($ch, [\r\n            CURLOPT_URL => 'https:\/\/httpbin.org\/ip',\r\n            CURLOPT_RETURNTRANSFER => true,\r\n            CURLOPT_TIMEOUT => 15,\r\n            CURLOPT_PROXY => $this->proxy_host . ':' . $this->proxy_port,\r\n            CURLOPT_PROXYTYPE => CURLPROXY_HTTP,\r\n            CURLOPT_PROXYUSERPWD => $this->proxy_username . ':' . $this->proxy_password,\r\n            CURLOPT_USERAGENT => 'IPNut-Test-Client\/1.0',\r\n            CURLOPT_SSL_VERIFYPEER => true\r\n        ]);\r\n\r\n        $response = curl_exec($ch);\r\n        $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE);\r\n        $connectTime = curl_getinfo($ch, CURLINFO_CONNECT_TIME);\r\n\r\n        if (curl_error($ch)) {\r\n            echo \"\u274c HTTP Proxy Connection Failed: \" . curl_error($ch) . \"\\n\";\r\n        } else {\r\n            echo \"\u2705 HTTP Proxy Connection Successful\\n\";\r\n            echo \"   Status Code: \" . $httpCode . \"\\n\";\r\n            echo \"   Connect Time: \" . round($connectTime, 2) . \"s\\n\";\r\n            $data = json_decode($response, true);\r\n            echo \"   Assigned IP: \" . ($data['origin'] ?? 'Unknown') . \"\\n\";\r\n        }\r\n\r\n        curl_close($ch);\r\n    }\r\n\r\n    \/**\r\n     * Comprehensive proxy testing\r\n     *\/\r\n    public function comprehensiveTest() {\r\n        echo \"\\n=== Comprehensive Proxy Test ===\\n\";\r\n\r\n        $testUrls = [\r\n            'https:\/\/httpbin.org\/ip',\r\n            'https:\/\/httpbin.org\/user-agent',\r\n            'https:\/\/httpbin.org\/headers'\r\n        ];\r\n\r\n        $proxyTypes = [\r\n            'SOCKS5' => CURLPROXY_SOCKS5,\r\n            'HTTP' => CURLPROXY_HTTP\r\n        ];\r\n\r\n        foreach ($proxyTypes as $proxyName => $proxyType) {\r\n            echo \"\\nTesting \" . $proxyName . \" Proxy:\\n\";\r\n\r\n            foreach ($testUrls as $testUrl) {\r\n                $ch = curl_init();\r\n                curl_setopt_array($ch, [\r\n                    CURLOPT_URL => $testUrl,\r\n                    CURLOPT_RETURNTRANSFER => true,\r\n                    CURLOPT_TIMEOUT => 10,\r\n                    CURLOPT_PROXY => $this->proxy_host . ':' . $this->proxy_port,\r\n                    CURLOPT_PROXYTYPE => $proxyType,\r\n                    CURLOPT_PROXYUSERPWD => $this->proxy_username . ':' . $this->proxy_password,\r\n                    CURLOPT_SSL_VERIFYPEER => true\r\n                ]);\r\n\r\n                $response = curl_exec($ch);\r\n                $success = !curl_error($ch) && curl_getinfo($ch, CURLINFO_HTTP_CODE) == 200;\r\n\r\n                if ($success) {\r\n                    echo \"  \u2705 \" . $testUrl . \" - Success\\n\";\r\n                } else {\r\n                    echo \"  \u274c \" . $testUrl . \" - Failed: \" . curl_error($ch) . \"\\n\";\r\n                }\r\n\r\n                curl_close($ch);\r\n            }\r\n        }\r\n    }\r\n\r\n    \/**\r\n     * Run all tests\r\n     *\/\r\n    public function runTests() {\r\n        echo \"=== IPNut Proxy Connectivity Test ===\\n\\n\";\r\n\r\n        $this->testSocks5Proxy();\r\n        $this->testHttpProxy();\r\n        $this->comprehensiveTest();\r\n\r\n        echo \"\\n\u2705 All proxy connectivity tests completed!\\n\";\r\n    }\r\n}\r\n\r\n\/\/ Run test tool if executed directly\r\nif (basename(__FILE__) == basename($_SERVER['PHP_SELF'])) {\r\n    $testTool = new ProxyTestTool();\r\n    $testTool->runTests();\r\n}\r\n?><\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t<div class=\"elementor-element elementor-element-ca6a65b e-flex e-con-boxed e-con e-parent\" data-id=\"ca6a65b\" data-element_type=\"container\">\n\t\t\t\t\t<div class=\"e-con-inner\">\n\t\t\t\t<div class=\"elementor-element elementor-element-3b64c01 elementor-widget elementor-widget-heading\" data-id=\"3b64c01\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h6 class=\"elementor-heading-title elementor-size-default\">4. Main Program Entry Point\nmain.php<\/h6>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-26289fa elementor-widget elementor-widget-code-highlight\" data-id=\"26289fa\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-php \">\n\t\t\t\t<code readonly=\"true\" class=\"language-php\">\n\t\t\t\t\t<xmp><?php\r\n\/**\r\n * Main Program - IPNut Proxy Integration Demo\r\n *\/\r\n\r\n\/\/ Include all class files\r\nrequire_once 'Socks5ProxyDemo.php';\r\nrequire_once 'HttpProxyDemo.php';\r\nrequire_once 'ProxyTestTool.php';\r\n\r\nclass MainProgram {\r\n\r\n    public function run() {\r\n        echo \"IPNut PHP Proxy Integration Demo\\n\";\r\n        echo \"================================\\n\\n\";\r\n\r\n        \/\/ Run connectivity tests first\r\n        $testTool = new ProxyTestTool();\r\n        $testTool->runTests();\r\n\r\n        echo \"\\n\" . str_repeat(\"=\", 60) . \"\\n\\n\";\r\n\r\n        \/\/ Run SOCKS5 proxy demonstrations\r\n        $socks5Demo = new Socks5ProxyDemo();\r\n        $socks5Demo->runAll();\r\n\r\n        echo \"\\n\" . str_repeat(\"=\", 60) . \"\\n\\n\";\r\n\r\n        \/\/ Run HTTP proxy demonstrations\r\n        $httpDemo = new HttpProxyDemo();\r\n        $httpDemo->runAll();\r\n\r\n        echo \"\\n\" . str_repeat(\"=\", 60) . \"\\n\";\r\n        echo \"\ud83c\udf89 All IPNut proxy integration demonstrations completed successfully!\\n\";\r\n    }\r\n}\r\n\r\n\/\/ Run main program\r\n$main = new MainProgram();\r\n$main->run();\r\n?><\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-e20fefb elementor-widget elementor-widget-heading\" data-id=\"e20fefb\" data-element_type=\"widget\" data-widget_type=\"heading.default\">\n\t\t\t\t\t<h6 class=\"elementor-heading-title elementor-size-default\">5. Execution Commands<\/h6>\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-a203656 elementor-widget elementor-widget-code-highlight\" data-id=\"a203656\" data-element_type=\"widget\" data-widget_type=\"code-highlight.default\">\n\t\t\t\t\t\t\t<div class=\"prismjs-default copy-to-clipboard \">\n\t\t\t<pre data-line=\"\" class=\"highlight-height language-php \">\n\t\t\t\t<code readonly=\"true\" class=\"language-php\">\n\t\t\t\t\t<xmp>#\u6587\u4ef6\u7ed3\u6784\uff1a\n# proxy_demo\/\n# \u251c\u2500\u2500 Socks5ProxyDemo.php    # SOCKS5 Proxy Implementation\n# \u251c\u2500\u2500 HttpProxyDemo.php      # HTTP Proxy Implementation  \n# \u251c\u2500\u2500 ProxyTestTool.php      # Connectivity Testing\n# \u2514\u2500\u2500 main.php               # Main Entry Point\n\n# Navigate to project directory\ncd proxy_demo\n\n# 1. Run SOCKS5 demo only\nphp Socks5ProxyDemo.php\n\n# 2. Run HTTP demo only  \nphp HttpProxyDemo.php\n\n# 3. Run connectivity tests only\nphp ProxyTestTool.php\n\n# 4. Run complete demonstration\nphp main.php<\/xmp>\n\t\t\t\t<\/code>\n\t\t\t<\/pre>\n\t\t<\/div>\n\t\t\t\t\t\t<\/div>\n\t\t\t\t<div class=\"elementor-element elementor-element-f46368b elementor-widget elementor-widget-text-editor\" data-id=\"f46368b\" data-element_type=\"widget\" data-widget_type=\"text-editor.default\">\n\t\t\t\t\t\t\t\t\t<p>Key Integration Notes:<\/p><ul><li><p class=\"ds-markdown-paragraph\">PHP Requirements: cURL extension must be enabled<\/p><\/li><li><p class=\"ds-markdown-paragraph\">Security: Enable SSL verification in production environments<\/p><\/li><li><p class=\"ds-markdown-paragraph\">Error Handling: Comprehensive exception handling included<\/p><\/li><li><p class=\"ds-markdown-paragraph\">Performance: Connection timeouts and rate limiting implemented<\/p><\/li><li><p class=\"ds-markdown-paragraph\">Credential Management: Replace example credentials with actual IPNut proxy details<\/p><\/li><\/ul><p>Best Practices:<\/p><ol start=\"1\"><li><p class=\"ds-markdown-paragraph\">Resource Management: Always close cURL handles<\/p><\/li><li><p class=\"ds-markdown-paragraph\">Error Handling: Check for cURL errors and HTTP status codes<\/p><\/li><li><p class=\"ds-markdown-paragraph\">Performance: Use concurrent requests for multiple operations<\/p><\/li><li><p class=\"ds-markdown-paragraph\">Security: Validate SSL certificates in production<\/p><\/li><\/ol><hr \/><p class=\"ds-markdown-paragraph\">Technical Support<br \/>For integration assistance or location-specific requirements:<\/p><ul><li><p class=\"ds-markdown-paragraph\">Email:\u00a0Support@ipnut.com<\/p><\/li><li><p class=\"ds-markdown-paragraph\">Live Chat: 24\/7 real-time support via official website<\/p><\/li><\/ul><p class=\"ds-markdown-paragraph\">*All code examples support both HTTP and SOCKS5 protocols with enterprise-grade authentication and security features.*<\/p>\t\t\t\t\t\t\t\t<\/div>\n\t\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t\t\t<\/div>\n\t\t","protected":false},"excerpt":{"rendered":"<p>After purchasing sta [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","template":"","meta":{"site-sidebar-layout":"no-sidebar","site-content-layout":"","ast-site-content-layout":"full-width-container","site-content-style":"default","site-sidebar-style":"default","ast-global-header-display":"","ast-banner-title-visibility":"","ast-main-header-display":"","ast-hfb-above-header-display":"","ast-hfb-below-header-display":"","ast-hfb-mobile-header-display":"","site-post-title":"disabled","ast-breadcrumbs-content":"","ast-featured-img":"disabled","footer-sml-layout":"","theme-transparent-header-meta":"","adv-header-id-meta":"","stick-header-meta":"","header-above-stick-meta":"","header-main-stick-meta":"","header-below-stick-meta":"","astra-migrate-meta-layouts":"default","ast-page-background-enabled":"default","ast-page-background-meta":{"desktop":{"background-color":"var(--ast-global-color-5)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"ast-content-background-meta":{"desktop":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"tablet":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""},"mobile":{"background-color":"var(--ast-global-color-4)","background-image":"","background-repeat":"repeat","background-position":"center center","background-size":"auto","background-attachment":"scroll","background-type":"","background-media":"","overlay-type":"","overlay-color":"","overlay-opacity":"","overlay-gradient":""}},"footnotes":""},"doc_category":[45],"doc_tag":[],"class_list":["post-818","docs","type-docs","status-publish","hentry","doc_category-development-documentation"],"year_month":"2026-06","word_count":191,"total_views":0,"reactions":{"happy":0,"normal":0,"sad":0},"author_info":{"name":"admin","author_nicename":"admin","author_url":"https:\/\/help.ipnut.com\/author\/admin\/"},"doc_category_info":[{"term_name":"Development Documentation","term_url":"https:\/\/help.ipnut.com\/docs\/development-documentation\/"}],"doc_tag_info":[],"lang":"en","translations":{"en":818,"cn":675},"knowledge_base_info":[],"knowledge_base_slug":[],"pll_sync_post":[],"_links":{"self":[{"href":"https:\/\/help.ipnut.com\/wp-json\/wp\/v2\/docs\/818","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/help.ipnut.com\/wp-json\/wp\/v2\/docs"}],"about":[{"href":"https:\/\/help.ipnut.com\/wp-json\/wp\/v2\/types\/docs"}],"author":[{"embeddable":true,"href":"https:\/\/help.ipnut.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/help.ipnut.com\/wp-json\/wp\/v2\/comments?post=818"}],"version-history":[{"count":7,"href":"https:\/\/help.ipnut.com\/wp-json\/wp\/v2\/docs\/818\/revisions"}],"predecessor-version":[{"id":1140,"href":"https:\/\/help.ipnut.com\/wp-json\/wp\/v2\/docs\/818\/revisions\/1140"}],"wp:attachment":[{"href":"https:\/\/help.ipnut.com\/wp-json\/wp\/v2\/media?parent=818"}],"wp:term":[{"taxonomy":"doc_category","embeddable":true,"href":"https:\/\/help.ipnut.com\/wp-json\/wp\/v2\/doc_category?post=818"},{"taxonomy":"doc_tag","embeddable":true,"href":"https:\/\/help.ipnut.com\/wp-json\/wp\/v2\/doc_tag?post=818"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}