2017-06-10 23 views
-3

変数に値を代入してURLに渡すとうまくいきます。Android AppからバックエンドPHPへのデータ投稿

$waybill=508518; 
$url = 'http://api.ecomexpress.in/track_me/api/mawbd/?awb='.$waybill.'&order=&[email protected]&[email protected]@@@'; 
$ch = curl_init();     // initiate curl 
curl_setopt($ch, CURLOPT_URL,$url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the output in  string format 
$output = curl_exec ($ch); 

しかし、私は必要なの私はbelow.ButのようなエンドPHPコードが

$waybill=$_POST['bill']; 
$url = 'http://api.ecomexpress.in/track_me/api/mawbd/?awb='.$waybill.'& order=&[email protected]&[email protected]@@@'; 

$ch = curl_init();     // initiate curl 
curl_setopt($ch, CURLOPT_URL,$url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the output in  string format 
$output = curl_exec ($ch); 
を働いていないその後ろに運送状値を掲載していますアンドロイドapp.Forから動的運送状番号を取得する必要があり、

エラー:未定義のインデックス法案

+0

'ますprint_r($ _ POST)みを使用して問題を解決しました;' print_r(file_get_contents( 'php:// input')); ' –

+0

のヘッダとパラメータに沿ってリクエストを記録してみましょう。あなたのデバイスからデータを送信すると、サーバーからの応答は何ですか? –

+0

間違ったリクエストのためにデータを投稿していない可能性があります。おそらく、あなたがあなたのAPIを消費しているクライアントに問題があります。あなたのデバイス –

答えて

0

は、次のコード

$waybill=$_POST['srt']; 
ob_start(); 
echo $_POST['srt']; 
$my = ob_get_contents(); 

$url='http://52.66.178.241//track_me/api/mawbd/? 
awb='.$my.'&order=&username=subhashree54396&password=su54nbh39tmed'; 
$ch = curl_init();     // initiate curl 
curl_setopt($ch, CURLOPT_URL,$url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // return the output in 
string format 
$output = curl_exec ($ch); 
print_r($output); 

curl_close($ch); 
関連する問題