2017-01-16 5 views
0
$cSession = curl_init(); 
curl_setopt($cSession,CURLOPT_URL,"http://hai:[email protected]@redmine.org/users/current.json"); 
curl_setopt($cSession,CURLOPT_RETURNTRANSFER,true); 
$userDetail = curl_exec($cSession); 

パスワードの後に​​続く文字をURLとみなします。ユーザー名またはパスワードを使用してredmine apiでログインする方法は、@文字である@

+0

こんにちは@ fahad-sulaimanです。答えを見た?コードを試しましたか?お手伝いしましたか? :) – yivi

+0

はい、それは助けました...ありがとうたくさん –

答えて

0

URL文字列に資格情報を入れないでください。このようにそれらを設定します。

curl_setopt($cSession, CURLOPT_URL,"http://redmine.org/user/current.json"); 
curl_setopt($cSession, CURLOPT_HTTPAUTH, CURLAUTH_ANY); 
curl_setopt($cSession, CURLOPT_USERPWD, "$username:$password"); 

そして、スタックオーバーフローを歓迎:)

0

あなたはユーザ名とパスワードをurlencode()必要があります。それは問題を解決するはずです。

$user = 'hai'; 
$pass = '[email protected]'; 

$creds = urlencode($user) . ':' . urlencode($pass) 

// result hai:hai%407 

次に、あなたがURLにその$creds文字列を渡す、またはCURLOPW_USERPWDなどができます。

+0

は、このURLを解読するredmine APIです。 –

+0

それはHTTPプロトコルの仕様に従ってください。 – drew010

関連する問題