Netkiller PHP 手札
PHP Language...
$Id: book.xml 642 2013-07-19 01:28:13Z netkiller $
版权 © 2008, 2009, 2010, 2011, 2012, 2013 Netkiller(Neo Chan). All rights reserved.
版权声明
转载请与作者联系,转载时请务必标明文章原始出处和作者信息及本声明。
|
|
$Date: 2013-07-19 09:28:13 +0800 (Fri, 19 Jul 2013) $
我的系列文档
3.4.3. HTTP 验证
配置 Nginx
server { listen 80; server_name api.example.com; charset utf-8; access_log /var/log/nginx/api.example.com.access.log main; auth_basic "Login"; auth_basic_user_file htpasswd; location / { root /www/example.com/api.example.com; index index.html index.php; } ... ... }
创建密码文件,请参考《Netkiller Web 手札》
# cat /etc/nginx/htpasswd neo:$apr1$mnT/iqg5$gn7m7xx.eflX9VK6p8hyj0
SoapClient 需要 login与password两个选项
<?php $options = array('uri' => "http://api.example.com", 'location'=>'http://api.example.com/soapserver.php', 'login'=>'neo', 'password'=>'chen', 'trace'=>true ); $client = new SoapClient(null, $options); try { echo $client->hello("Hello"); print_r($client->sum(10,20)); } catch (Exception $e) { echo 'Caught exception: ', $e->getMessage(), "\n"; }