donglu5728 2013-09-29 04:28
浏览 108

HTTP基本身份验证使用“授权:基本”失败.base64_encode(“$ user:$ pass”)

I tried this code in my local PHP server... everything works perfectly.. however when I uploaded this script to web hosting server, the authentication did not work. Somebody can explain why this script doesn't work on webserver?

"Authorization: Basic " . base64_encode("$username:$password")

Script:

$url = 'http://xxx.xxx.xxx.xxx:9080/apex/api/query?filtername=UNITSUMM&PARM_CONTAINER='.$contrNo.'&operatorId=BIG&complexId=KSA&facilityId=DMM&yardId=RRY';
$context = stream_context_create(array(
    'http' => array(
    'header'  => "Authorization: Basic " . base64_encode("$username:$password")
    )
));

$data = @file_get_contents($url, false, $context);
$convert = explode("
", $data);
  • 写回答

1条回答 默认 最新

  • doubi6669 2013-09-29 12:28
    关注

    It would be helpful if you could post whatever error message you're seeing, or you can find in the error logs.

    It might be that your hosting provider doesn't allow outgoing connections to port 9080, or is blocking your connection based on some other criteria.

    You might be able to debug your script if you print out the value of base64_encode("$username:$password") - perhaps one of these variables isn't getting set to the correct value.

    评论

报告相同问题?

悬赏问题

  • ¥15 matlab中使用gurobi时报错
  • ¥15 WPF 大屏看板表格背景图片设置
  • ¥15 这个主板怎么能扩出一两个sata口
  • ¥15 不是,这到底错哪儿了😭
  • ¥15 2020长安杯与连接网探
  • ¥15 关于#matlab#的问题:在模糊控制器中选出线路信息,在simulink中根据线路信息生成速度时间目标曲线(初速度为20m/s,15秒后减为0的速度时间图像)我想问线路信息是什么
  • ¥15 banner广告展示设置多少时间不怎么会消耗用户价值
  • ¥16 mybatis的代理对象无法通过@Autowired装填
  • ¥15 可见光定位matlab仿真
  • ¥15 arduino 四自由度机械臂