search

Home  >  Q&A  >  body text

php - How to dynamically change IP in the program

How to implement the function of dynamically changing IP in the program, the IP address can be purchased from a certain treasure

某草草某草草2749 days ago730

reply all(2)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-18 10:49:10

    That is, proxy, it depends on your program to implement it, proxy

    reply
    0
  • ringa_lee

    ringa_lee2017-05-18 10:49:10

    If your program is a client to request others, you can use http proxy. For example, how to configure http proxy using curl:

    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'http://baidu.com');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_PROXYAUTH, CURLAUTH_BASIC); //代理认证模式
    curl_setopt($ch, CURLOPT_PROXY, "xxx.xxx.xxx.xxx"); //代理服务器地址
    curl_setopt($ch, CURLOPT_PROXYPORT, 80); //代理服务器端口
    //curl_setopt($ch, CURLOPT_PROXYUSERPWD, ":"); //http代理认证帐号,username:password的格式
    curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP); //使用http代理模式
    $file_contents = curl_exec($ch);

    reply
    0
  • Cancelreply