2017-05-19 9 views
-3

私はphpを使って他のURLを呼び出す方法..?

http://192.168.1.220/cgi-bin/handle_login.tcl

が、カールを試みたときには、以下

The requested URL was not found on this server. The link on the referring page seems to be wrong or outdated. Please inform the author of that page about the error. 

私のphpで私に次のエラーを与えてその作業罰金をアプリ配達員に次のURLを打ったときコード

<?php 
    $postData = array(
    'user' => 'admin', 
    'pw' => 'admin', 
    'submit' => 'Login' 
    ); 

    // Setup cURL 
    $ch = curl_init('http://192.168.1.220/cgi-bin/handle_login.tcl'); 
    curl_setopt_array($ch, array(
    CURLOPT_POST => TRUE, 
    CURLOPT_RETURNTRANSFER => TRUE, 
    CURLOPT_HTTPHEADER => array('Content-Type: application/x-www-form-urlencoded' 
), 
    CURLOPT_POSTFIELDS => json_encode($postData) 
)); 

// Send the request 
    $response = curl_exec($ch); 

var_dump($response); 

// Check for errors 
    if($response === FALSE){ 
    die(curl_error($ch)); 
    } 

    // Decode the response 
    $responseData = json_decode($response, TRUE); 

// Print the date from the response 
echo $responseData['published']; 
?> 
+1

あなたは、スタックオーバーフローがどのように動作するかの深刻な誤解であるように思わ答えです。 [ヘルプ]、主に[ask]と[Be Nice](http://stackoverflow.com/help/be-nice)を確認してください。 –

+0

@ Nitish..u upvoteの質問を投稿すると思います....前の質問の1つで、ユーザーは喜んでdownvotedし、いくつかの無責任な回答を投稿し、緑のチックとupvoteのために私に尋ねた。エラーが表示されたらどうなったのですか?あなたが私に通知するのを手助けしたいのであれば、私は間違いを覚えています... – Pradeep

+0

Lol ... @Nitish ....私はuveが私の投稿を通して行っていると思います....そのポストiveのために自分自身で答えを投稿したと思う..... – Pradeep

答えて

0

私は自分のコード内のエラーを整流してきたと私は答えを希望しまった...

は以下

$ch = curl_init(); 
    curl_setopt($ch, CURLOPT_URL,"URL"); 
    curl_setopt($ch, CURLOPT_POST, 1); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, 
    "key1=value1&key2=value2&key3=value3");   
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 

    // Send the request 
    $response = curl_exec($ch); 
    curl_close ($ch); 
    echo "$response"; 
+0

私は誰がこの投稿をdownvotedいけない..しかし、私のために、上記のコードはうまく動作しています... – Pradeep

関連する問題