バージョン選択

フォーラム

メニュー

オンライン状況

41 人のユーザが現在オンラインです。 (31 人のユーザが フォーラム を参照しています。)
登録ユーザ: 0
ゲスト: 41
もっと...

サイト内検索

質問 > その他 > file_get_contents()を使った自動ログイン処理がうまく動きません。

その他

新規スレッドを追加する

フラット表示 前のトピック | 次のトピック
投稿者 スレッド
ynuma
投稿日時: 2015/7/8 13:56
対応状況: 確認中
新米
登録日: 2014/3/24
居住地:
投稿: 1
file_get_contents()を使った自動ログイン処理がうまく動きません。
外部システムからIDとパスワードを渡して、EC-CUBEに自動ログインさせるプログラムを考えています。
下記のようなサンプルプログラムを作って実行しましたら、次のエラーが発生しました。
※ドメイン、メール等、一部「xxx」で伏字にしています

Warning: file_get_contents(http://xxx.xxx.xxx.xxx/shop/frontparts/login_check.php): failed to open stream: HTTP request failed! HTTP/1.1 500 Internal Server Error in /export/sd210/www/jp/r/e/gmoserver/6/1/sd0454461/xxx.xxx.xxx.xxx/eccube_ex1.php on line 38

試行錯誤しまして、POSTデータを設定している下記の1行をコメントにすると
エラーは出なくなるのですが、未ログインの状態でトップページが表示されます。

"transactionid" => $transactionid,

これを渡さない事にはログインが出来ないのでコメントにするわけにはいかず
指定すると上記のエラーが出て手詰まり状態です。

何か改善方法がないか、または、別の方法で自動ログイン出来ないか
情報をいただけると助かります。

よろしくお願いいたします。


---サンプルプログラム---
<?php
$html = file_get_contents('http://xxx.xxx.xxx.xxx/shop/');

if (preg_match("/name=\"transactionid\" value=\"(.+?)\"/", $html, $match)) {
//echo $match[0];
$pos = strpos($match[0], "value=\"");
//echo str_replace("\"", "", substr($match[0], $pos+7));
$transactionid = str_replace("\"", "", substr($match[0], $pos+7));
//echo $transactionid;

//post date
$data = array(
"mode" => "login",
"transactionid" => $transactionid,
"url" => "/shop/",
"login_email" => "xxx@xxx.xxx.xxx";,
"login_memory" => "1",
"login_pass" => "xxxxx"
);

$data = http_build_query($data, "", "&");

//header
$header = array(
"Content-Type: application/x-www-form-urlencoded",
"Content-Length: ".strlen($data)
);

$opts = array(
"http" => array(
"method" => "POST",
"header" => implode("\r\n", $header),
"content" => $data
)
);

$context = stream_context_create($opts);
echo file_get_contents('http://xxx.xxx.xxx.xxx/shop/frontparts/login_check.php', false, $context);

}



?>
フラット表示 前のトピック | 次のトピック


題名 投稿者 日時
 » file_get_contents()を使った自動ログイン処理がうまく動きません。 ynuma 2015/7/8 13:56
     Re: file_get_contents()を使った自動ログイン処理がうまく動きません。 tsuji 2015/7/14 9:31

 



ログイン


EC-CUBE公式 Amazon Payプラグイン

統計情報

総メンバー数は88,871名です
総投稿数は109,999件です

投稿数ランキング

1
seasoft
7367
2
468
3217
3
AMUAMU
2712
4
nanasess
2313
5
umebius
2085
6
yuh
1819
7
h_tanaka
1646
8
red
1570
9
mcontact
1295
10
tsuji
958
11
fukap
907
12
shutta
835
13
tao_s
799
14 ramrun 789
15 karin 689
16 sumida 641
17
homan
633
18 DELIGHT 572
19
patapata
502
20
flealog
485


ネットショップの壺

EC-CUBEインテグレートパートナー

Copyright© EC-CUBE CO.,LTD. All Rights Reserved.