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

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • dompower
    New Member
    • Sep 2013
    • 1

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

    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:$pass word")**

    script:

    Code:
    $url = 'http://xxx.xxx.xxx.xxx:9080/apex/api/query?filtername=UNITSUMM&PARM_CONTAINER=containerNo&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("\n", $data);
    Last edited by Rabbit; Sep 29 '13, 05:27 PM. Reason: Please use [CODE] and [/CODE] tags when posting code or formatted data.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    what does your setting of allow_url_fopen in your php.ini say?

    Comment

    Working...