Advertisement
Guest User

Untitled

a guest
Oct 27th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.22 KB | None | 0 0
  1. <route url="/V1/customers/authenticate/:email/:password" method="GET">
  2. <service class="MagentoCustomerApiAccountManagementInterface" method="authenticate"/>
  3. <resources>
  4. <resource ref="anonymous"/>
  5. </resources>
  6. </route>
  7.  
  8. $userData = array("username" => "your_username", "password" => "your_password");
  9. $ch = curl_init("http://localhost/magento/index.php/rest/V1/integration/admin/token");
  10. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
  11. curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData));
  12. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  13. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Lenght: " . strlen(json_encode($userData))));
  14.  
  15. $token = curl_exec($ch);
  16.  
  17. $ch = curl_init("http://localhost/magento/index.php/rest/V1/customers/authenticate/".
  18. "roni_cost@example.com". //username/email
  19. "/".
  20. "roni_cost3@example.com" //password
  21. );
  22. curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "GET");
  23. curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  24. curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));
  25.  
  26. $result = curl_exec($ch);
  27.  
  28. echo($result);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement