gpt4 book ai didi

ruby - 如何通过 Magento SOAP API 使用 savon gem

转载 作者:太空宇宙 更新时间:2023-11-03 17:18:23 26 4
gpt4 key购买 nike

我如何访问 Magento SOAP API使用 savon gem 。有没有我可以用来快速入门的示例?

谢谢

最佳答案

试试这个让你开始:

require 'rubygems'
require 'savon'

client = Savon::Client.new do
wsdl.document = "http://your.server.here/index.php/api/?wsdl"
end

response = client.request :login do
soap.body = { :username => 'soapuser', :apiKey => 'myapikey' }
end

if response.success? == false
puts "login failed"
System.exit(0)
end

session = response[:login_response][:login_return];

response = client.request :call do
soap.body = {:session => session,:method => 'catalog_product.list' }
end

# fetching all products
if response.success?
# listing found products
response[:call_response][:call_return][:item].each do |product|
puts "-------------------------------------------"
product = product[:item]
product.each do |pkey|
puts "#{pkey[:key]} -> #{pkey[:value]}"
end
end
end

#logging out
response = client.request :endSession do
soap.body = {:session => session}
end
puts response.to_hash

关于ruby - 如何通过 Magento SOAP API 使用 savon gem,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5778716/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com