Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- [oauth_consumer_key] => x...0
- [oauth_consumer_secret] => j...l
- [store_base_url] => http://magento.example.com/
- [oauth_consumer_secret] => 5...n
- /oauth/token/request
- /oauth/token/access
- $credentials = new OAuthCommonConsumerCredentials($consumerKey, $consumerSecret, $magentoBaseUrl);
- $oAuthClient = new OauthClient($credentials);
- // get admin Token to create the customer Account in realm Data stores
- $ch = curl_init('http://openam/json/authenticate');
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'X-OpenAM-Username: uradmin',
- 'X-OpenAM-Password: urpassword',
- 'Accept-API-Version: resource=2.0, protocol=1.0'
- )
- );
- $result = curl_exec($ch);
- curl_close($ch);
- if (array_key_exists('tokenId', json_decode($result, true))) {
- $adminToke = json_decode($result, true)["tokenId"];
- //create user in OpenAM Customer Realm
- $data = array("username" => $email, "userpassword" => $password,"mail"=>$email);
- $data_string = json_encode($data);
- $ch = curl_init('http://openam/json/admingroup/users/?_action=create');
- curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST");
- curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($ch, CURLOPT_HTTPHEADER, array(
- 'Content-Type: application/json',
- 'iplanetDirectoryPro:'.$adminToke.''
- )
- );
- curl_close($ch);
- // create Magento Customer in Magento DB
- $customer=$this->_objectManager->create('MagentoCustomerModelCustomer');
- $customer->setWebsiteId($this->_objectManager->create('SupplierDelegateHelperData')->getCurrentWebsiteId());
- $customer->setStoreId($this->_objectManager->create('ManufactureDealersHelperData')->getCurrentStoreId());
- $customer->setGroupId(5);
- $customer->setFirstname($firstName);
- $customer->setLastname($lastName);
- $customer->setEmail($email);
- $customer->setPassword($password);
- try{
- $customer->save();
- }
- catch (Exception $exception)
- {
- $this->messageManager->addError($exception->getMessage());
- return $this->resultRedirectFactory->create()->setPath('*/*/register');
- }
- //save SupplierDelgate Model
- $model = $this->_objectManager->create('ManufactureDealersModelSuppliers');
- $model->setDelegateId($customer->getId());
- $model->setParentSupplierId($supplierParentId);
- $model->setRole($role);
- $model->save();
- $address =$this->_objectManager->create('MagentoCustomerModelAddress');
- $address->setCustomerId($customer->getId())
- ->setFirstname($customer->getFirstname())
- ->setMiddleName($customer->getMiddlename())
- ->setLastname($customer->getLastname())
- ->setCountryId('SA')
- //->setRegionId('1') //state/province, only needed if the country is USA
- ->setPostcode($postCode)
- ->setCity($city)
- ->setTelephone($telephone)
- ->setFax($fax)
- ->setCompany($company)
- ->setStreet($street)
- ->setIsDefaultBilling('1')
- ->setIsDefaultShipping('1')
- ->setSaveInAddressBook('1');
- try{
- $address->save();
- $this->_objectManager->create('ManufactureDealersHelperData')->setCustomerStatus("Active",$customer->getId());
- $this->messageManager->addSuccess(__('registration have been completed Successfully '));
- $this->_redirect('customer/account/login/');
- }
- catch (Exception $e) {
- Zend_Debug::dump($e->getMessage());
- }
- Fatal error: Uncaught Error: Class 'OauthClient' not found in /public_html/magento2/checklogin.php:22 Stack trace: #0 {main} thrown in /public_html/magento2/checklogin.php on line 22
Add Comment
Please, Sign In to add comment