badlogic

get api and store the converted api to array and save it in directory using curl

Oct 13th, 2021 (edited)
251
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.76 KB | None | 0 0
  1. file1.php
  2. <?php
  3. $arrData = [['mobileno'=>'09181234522','message'=>'1this is a test message.'],['mobileno'=>'09181234567','message'=>'2this is a test message.']];
  4. echo json_encode($arrData);
  5.  
  6.  
  7. file2.php
  8. <?php
  9. $ch = curl_init();
  10. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  11. curl_setopt($ch, CURLOPT_URL,'http://192.168.50.17/file1.php');
  12. $result=curl_exec($ch);
  13. curl_close($ch);
  14. $message = json_decode($result, true);
  15. foreach($message as $key=> $value){
  16.     $length = 10;
  17.     $unique_number= substr(str_shuffle('0123456789abcdefghijklmnopqrstuvwxyz'),1,$length);
  18.     file_put_contents('send'.$unique_number,$value['mobileno']."\n"."\n".$value['message']);
  19. }
  20.  
  21.  
  22. https://stackoverflow.com/questions/14193131/give-777-permission-to-dynamically-created-file-in-php
Add Comment
Please, Sign In to add comment