2017-09-15 8 views
0

PHPを使用してクライアントにデータを送信する電報ロボットを開発しています。 ドメイン名がすでに登録されているかどうかを確認するための電信ボットです。登録されていない場合、ユーザーはそれを登録できます。すでに登録されている場合は、登録されたドメイン名のwhois情報を返します。PHPがtxtファイルにデータを送信/保存する

これは私のコードの部分的な一部です:

if($inText) { 
    $domain = trim($inText); 
    if(substr(strtolower($domain), 0, 7) == "http://") $domain = substr($domain, 7); 
    if(substr(strtolower($domain), 0, 4) == "www.") $domain = substr($domain, 4); 
     if(ValidateIP($domain)) { 
     $caption = LookupIP($domain); 
    } 
    elseif(ValidateDomain($domain)) { 
     $caption = LookupDomain($domain); 
     //$errorchars = array('no match','No results','NOT FOUND'); 
     //strtolower($errorchars) 
     if(strpos(strtolower($caption),'no match') !== false or strpos(strtolower($caption),'no results') !== false or strpos(strtolower($caption),'not found') !== false){ 
      $caption = " 
      Domain $domain is available to register 

      You can register it here : 
      http://something.com/?register=$domain 



    static text 
     static text 
    ☎️ static text 
     ";} 
      else{ 
       $caption = " 
    Dear user, 

the domain $domain is already registered! 

Domain Whois info: 

$caption 

The Domain name is already registered      

    static text 
     static text 
    ☎️ static text 
"; 
     } 
    } 
    else $caption = "Entry is invalid"; 
} 
    $photo = "https://kmc.im/glassbot/1.jpg"; 
    //$caption = LookupDomain ($inText); 

    $output1 = " 

    static text 
     static text 
    ☎️ static text 
    "; 

    $sendP = sendPhoto($cid, $photo, $botapi ,$output1,$encodedMarkup) ; 
    $sendP1 = sendMessage($cid, $caption, $botapi ,$encodedMarkup) ; 
    $sendP2 = sendMessage($adminID, "$caption \n ID : $cid \n User : @$uname", $botapi ,$encodedMarkup) ; 
} 


?> 

コードがprefectly動作し、それが仕事が右ありません。それが言う

Domain Whois info: 

$caption 

は、ドメイン名が既に登録されている場合、$のキャプションは、WHOIS情報を返すです。

私がしたいことは、$ captionの値をテキストファイルに保存する関数を追加することです。だから私はそれを記録することができます。

私はしばらくそれに苦しんでおり、それを正しくすることができませんでした。

あなたのお手伝いがありがとうございます。

あなたは

+0

'file_put_contents()'? http://php.net/manual/en/function.file-put-contents.php – JustBaron

答えて

1

あなたが唯一の1つのコマンドでファイルにデータを保存するためにfile_put_contents機能を使用することができますありがとうございました。

例:

file_put_contents("yourfilenametosavedata.txt", $caption); 

それです。

+0

だから、$ captionの後にこの行を追加するだけですか?どうすればそれらを組み合わせることができますか? –

+0

私はPHPの専門家ではありません。私はこのコードをどのように私のものと組み合わせるのか分かりません。 –

+1

@ArtaS、はい。たとえば、 "$ sendP1 = sendMessage($ cid、$ caption、$ botapi、$ encodedMarkup);という行の後に"行を追加します:file_put_contents($ domain。 "txt"、$ caption);これはあなたのPHPファイルと同じフォルダに "entereddomainname.txt"というファイルを保存します。または、次の行を使用します。file_put_contents($ cid。 "_"。$ domain。 "。txt"、$ caption);次に、 "clientid_entereddomainname.txt"というファイルを取得します。 – Xplatforms

関連する問題