Autor | Zpráva | ||
---|---|---|---|
Soob Profil * |
#1 · Zasláno: 5. 9. 2014, 10:22:25
Ahoj. Potřebuji pomocí XML-RPC verifikovat držitele ISICu.
Našel jsem od Jakuba Vrány funkci, která se o výměnu dat pomocí XML-RPC postará. Fungovala, ale problém je v tom, že jsem to zkoušel na veřejně dostupném adresáři (bez hesla). Testovací prostředí pro tu verifikaci je totiž pod heslem: Testovací URL: http://gts-ncdb.orchitech.net/ws/referral Uživatelské jméno: testbs Heslo: testbs Otázka zní, jakým způsobem heslo zadat. Přidat ho do hlavičky? Jak? PHP kód zde: function xmlrpc($url, $method, $params, $types = array(), $encoding = 'utf-8') { foreach ($types as $key => $val) { xmlrpc_set_type($params[$key], $val); } $context = stream_context_create(array('http' => array( 'method' => "POST", 'header' => "Content-Type: text/xml\r\n", 'content' => xmlrpc_encode_request($method, $params, array('encoding' => $encoding)), ))); return xmlrpc_decode(file_get_contents($url, false, $context), $encoding); } $pole_parametru = array('S123456789000A','John Doe','EXTOFFER','test'); $odpoved = xmlrpc("http://gts-ncdb.orchitech.net/ws/referral", "Referral.useCard", $pole_parametru) . "\n"; print_r($odpoved); Jinak to hází tuto chybu: Warning: file_get_contents(http://gts-ncdb.orchitech.net/ws/referral) [function.file-get-contents]: failed to open stream: HTTP request failed! HTTP/1.1 401 Unauthorized |
||
blaaablaaa Profil |
#2 · Zasláno: 5. 9. 2014, 11:17:25
Stacilo pouzit google:
$context = stream_context_create(array( 'http' => array( 'header' => "Authorization: Basic " . base64_encode("$username:$password") ) )); $data = file_get_contents($url, false, $context); Sending a username and password with PHP file_get_contents() |
||
Časová prodleva: 10 let
|
0