Guest User

Untitled

a guest
Aug 23rd, 2018
579
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.68 KB | None | 0 0
  1. $adminUrl='http://magento-148486-425775.cloudwaysapps.com/index.php/rest/V1/integration/admin/token';
  2. $ch = curl_init();
  3. $data = array("username" => "abc@gmail.com", "password" => "abc@123.");
  4.  
  5. $data_string = json_encode($data);
  6. $ch = curl_init($adminUrl);
  7. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  8. curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
  9. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  10. curl_setopt($ch, CURLOPT_HTTPHEADER, array(
  11. 'Content-Type: application/json',
  12. 'Content-Length: ' . strlen($data_string))
  13. );
  14. $token = curl_exec($ch);
  15. $token= json_decode($token);
  16. $randno=rand();
  17. $email=$randno."@email.com";
  18. $customerData = [
  19. 'customer' => [
  20. "id" => 25,
  21. "email" => 'subhra@email.com',
  22. "firstname" => $randno,
  23. "lastname" => $randno,
  24. "storeId" => 1,
  25. "websiteId" => 1,
  26. "customAttributes" => [
  27. ],
  28.  
  29. "addresses" => [
  30.  
  31. ]
  32. ],
  33. "password" => 'sbha123@'
  34. ];
  35. $headers = array("Authorization: Bearer $token");
  36. $requestUrl='http://magento-148486-425775.cloudwaysapps.com/index.php/rest/V1/customers/25';
  37.  
  38. //echo $requestUrl;exit;
  39. $ch = curl_init();
  40. $ch = curl_init($requestUrl);
  41. curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  42. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  43. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  44. curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($customerData));
  45. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . $token));
  46. $result = curl_exec($ch);
  47.  
  48. $result = json_decode($result, 1);
  49.  
  50. $adminUrl1='http://magento-148486-425775.cloudwaysapps.com/index.php/rest/V1/integration/customer/token';
  51. $ch1 = curl_init();
  52. $data1 = array("username" => 'subhra@email.com', "password" => 'sbha123@');
  53.  
  54. $data_string1 = json_encode($data1);
  55. $ch1 = curl_init($adminUrl1);
  56. curl_setopt($ch1, CURLOPT_CUSTOMREQUEST, "POST");
  57. curl_setopt($ch1, CURLOPT_POSTFIELDS, $data_string1);
  58. curl_setopt($ch1, CURLOPT_RETURNTRANSFER, true);
  59. curl_setopt($ch1, CURLOPT_HTTPHEADER, array(
  60. 'Content-Type: application/json',
  61. 'Content-Length: ' . strlen($data_string1))
  62. );
  63. $token1 = curl_exec($ch1);
  64. echo $token1;
  65.  
  66. {"message":"You did not sign in correctly or your account is temporarily disabled.","trace":"#0 [internal function]:
Add Comment
Please, Sign In to add comment