Skip to content

Instantly share code, notes, and snippets.

@mrkhoa99
Created February 7, 2017 07:12
Show Gist options
  • Save mrkhoa99/66a39fdc46958c721bb5160864d27ad9 to your computer and use it in GitHub Desktop.
Save mrkhoa99/66a39fdc46958c721bb5160864d27ad9 to your computer and use it in GitHub Desktop.
<?php
$userData = ["username" => "customeruser@gmail.com", "password" => "123456"];
$ch = curl_init("http://magen2.loc/rest/V1/integration/customer/token");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($userData));
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Content-Lenght: " . strlen(json_encode($userData))));
$token = curl_exec($ch);
$emailcontent = [
"email"=> "test@gmail.com",
"template" => "email_reset", // Using template email reset
"websiteId" => 1
];
$ch = curl_init("http://magen2.loc/rest/V1/customers/password");
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT"); // Put method
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($emailcontent));
curl_setopt($ch, CURLOPT_HTTPHEADER, array("Content-Type: application/json", "Authorization: Bearer " . json_decode($token)));
$result = curl_exec($ch);
$result = json_decode($result, 1);
echo '<pre>';print_r($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment