Advertisement
Guest User

Untitled

a guest
Dec 11th, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.32 KB | None | 0 0
  1. <?php
  2.  
  3. namespace App\Jobs;
  4.  
  5. use Illuminate\Bus\Queueable;
  6. use Illuminate\Queue\SerializesModels;
  7. use Illuminate\Queue\InteractsWithQueue;
  8. use Illuminate\Contracts\Queue\ShouldQueue;
  9. use Illuminate\Foundation\Bus\Dispatchable;
  10. use App\Product;
  11.  
  12. class CheckAndSendAccount implements ShouldQueue
  13. {
  14. use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
  15.  
  16. /**
  17. * Create a new job instance.
  18. *
  19. * @return void
  20. */
  21. public function __construct()
  22. {
  23. //
  24. }
  25.  
  26. /**
  27. * Execute the job.
  28. *
  29. * @return void
  30. */
  31. public function handle()
  32. {
  33. $products = Product::with('product_bodies')->get();
  34.  
  35. foreach ($products as $product) {
  36. foreach ($product->product_bodies as $prod) {
  37. $res = $this->checkAccountData($prod->product_body);
  38.  
  39. if (!$res) {
  40. $prod->delete();
  41. }
  42. }
  43. }
  44. }
  45.  
  46. public function checkAccountData($data)
  47. {
  48. $login = explode(':', $data)[0];
  49. $password = explode(':', $data)[1];
  50.  
  51. $result = @file_get_contents("https://oauth.vk.com/token?grant_type=password&client_id=2274003&client_secret=hHbZxrka2uZ6jB1inYsH&username={$login}&password={$password}");
  52.  
  53. return $result;
  54. }
  55. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement