การสร้าง Application ล็อกอิน มาเจนโต้ Api
การสร้าง application ไม่ว่าจะเป็น web , web application หรือ โปรแกรมบน mobile ทั้ง android , ios โดยการใช้ api ของผู้ให้บริการ service ในที่นี้จะกล่างถึง magento
มาเจนโต้ เว็บ cms มากความสามารถในการสร้างร้านค้า บริหารจัดการออนไลน์ จะมีบริการเซอร์วิสให้ หากเราต้องการจะสร้าง โปรแกรมต่างๆ เพื่อให้งาน ไม่ว่าจะเป็นดูสินค้า ดูลูกค้า หรือจัดการผ่านโปรแกรมที่ต้องการสร้างขึ้นอีกแพตฟอร์มหนึ่งก็สามารถทำได้ โดยการเรียกใช้ เซอร์วิสจัดการ
1. เริ่มต้น โดยการตั้งค่า Activating Web Services ก่อน โดยเข้าไปจัดการที่หลังบ้าน ล็อกอินเข้าไปจัดการ
Web Services give you the ability to integrate with third-party applications by granting them permission to access specific store resources and data.
Step 1: Create a Web Service Role
- From the Admin menu, select System > Web Services > Roles.
- Click the Add New Role button.
- In the Role Information section, enter a Role Name such as “API.”
- In the panel on the left, select Role Resources. Then do one of the following:
- To enable full access to customer, catalog, and sales information, set Resource Access to “All.”
- To provide limited access to data, set Resource Access to “Custom.” Then, select the checkbox of each resource that is available to this role.
- By default, when a area is selected, full access is granted. You can accept the default, specify the actions that a person is allowed to take. Specific types of access are listed under many of the resource links, so it is easy to determine exactly what a user is allowed to do with each resource.
- When complete, click the Save Role button.

Web Services - Roles

Role Information
Step 2: Create a Web Service User
- From the Admin menu, select Web Services > Users.
- Click the Add New User button. (apiUser)
- Complete the following fields:
- User Name
- First Name
- Last Name
- In the API Key field, enter a verification key or password. This is the credential that third-party web services must use to access your Magento Go store. (apiKey)
- To confirm, re-enter the key in the API Key Confirmation field.
- In the panel on the left, select User Role. Then, select a Role for the user.
- When complete, click the Save User button.
from : http://go.magento.com/support/kb/entry/name/setting-web-services/
การเชื่อมต่อ service
To connect to Magento SOAP web services, load the WSDL into your SOAP client from either of these URLs:
http://magentohost/api/?wsdl
http://magentohost/api/soap/?wsdl
where magentohost is the domain for your Magento host.
Examples
Request Example SOAP V1
$client = new SoapClient('http://magentohost/api/soap/?wsdl'); // If somestuff requires api authentification, // then get a session token $session = $client->login('apiUser', 'apiKey'); $result = $client->call($session, 'catalog_product.list'); var_dump($result); // If you don't need the session anymore //$client->endSession($session);
from : http://www.magentocommerce.com/api/soap/catalog/catalogProduct/catalog_product.list.html
การสร้างฟอร์มล็อกอิน
จะใช้ โมดูล Customer ดังนี้ Module: Mage_Customer > http://www.magentocommerce.com/api/soap/
customer/customer.html ในการจัดการ ปํญหาคือ password ที่ต้องนำมาสร้างระบบ login จะถูกเข้ารหัส โดยมาเจนโต้ เป็นรหัส md5 โดยการ random salt (จะเรียกว่ารหัสเกลือก็แล้วกัน) เพื่อนำไปเข้ารหัส 2 ตัว
ดังนั้นพาสเวิร์ด ที่ถูกเข้ารหัสแล้วจะไม่เหมือนกัน ถึงแม้จะตั้งรหัสผ่านเหมือนกันก็ตาม รหัส md5 จะมีทั้งหมด ๓๒ ตัวอักษร , อักขระพิเศษ ๑ ตัวอักษร, และ รหัสเกลืออีก ๒ ตัวอักษร รวมเป็น ๓๕ ตัวอักษร
การเข้ารหัสเพื่อนำไป ตรวจการล็อกอินในโปรแกรมของเรา ทำได้โดยการนำ รหัสเกลือ ๒ ตัวมา จากดาต้าเบส วางไว้ด้านหน้า (จะแทนตัวอักษรรหัสเกลือด้วย xx) ดังนี้
xxzzzz... จะให้ z เป็นรหัสที่รับเข้ามา สมมุติให้รหัสเกลือ 5U และรหัสที่รับเข้ามาดังนี้ "123456" จะได้
5U123456 นำรหัสนี้ไปเข้า md5 สามารถใช้ web application ทดสอบได้ ค้นหาในกูเกิล text to md5 มีให้เลือกใช้งานมากมายหลายเว็บไซต์ หรือผู้ที่มีทักษะการเขียนโปรแกรม สามารถใช้การโค้ดดิ้ง php ได้ด้วยคำสั่งนี้ echo md5("text"); จะได้ md5 = 6c7196cc98570cf162a63d80a52d96f5 นำไปตรวจสอบเพื่อเข้ารหัสล็อกอิน
Comments
Post a Comment