Skip to content

Instantly share code, notes, and snippets.

@jamesBan
Created August 10, 2021 10:00
Show Gist options
  • Save jamesBan/e5723d0288b7b9eebe5e8788f201dbca to your computer and use it in GitHub Desktop.
Save jamesBan/e5723d0288b7b9eebe5e8788f201dbca to your computer and use it in GitHub Desktop.
指定域名对应ip请求
<?php
$data = [];
$ch = curl_init();
curl_setopt($ch, CURLOPT_RESOLVE, ['api.example.com:80:127.0.0.1']);
curl_setopt($ch, CURLOPT_PORT, 80);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
curl_setopt($ch, CURLOPT_URL, 'http://api.example.com/api/test/123');
$response = curl_exec($ch);
var_dump($response);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment