$host = APP_DEV ? 'ecode.com' : 'ecode.yinuoinfo.com'; $uri = 'http://' . $host . '/ApiJsonTicket/sendticket'; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $uri); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 10); curl_setopt($ch, CURLOPT_TIMEOUT, 30); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'json' => json_encode($apiPost) )); $HttpResponse = curl_exec($ch); curl_close($ch);
上面这种方式可以在php中访问另外的一个页面并返回一个数据。