Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Passing and array to an API
Message
 
 
To
09/05/2011 15:16:24
General information
Forum:
Visual FoxPro
Category:
Web Services
Environment versions
Visual FoxPro:
VFP 9 SP2
OS:
Windows XP
Application:
Web Service
Miscellaneous
Thread ID:
01510086
Message ID:
01510098
Views:
60
I don't know the answer to your question but the Wonder Lake byline grabbed my attention. I am in Round Lake, probably 10 miles northeast of you. It's always fun to meet other VFP folks and I would be up for lunch some day.

>I think the answer is a SOAP API. Info here http://www.magentocommerce.com/support/magento_core_api its all new to me.
>
>>I'm confused. Is this a web service or a binary API. If it's a web service, the data will come as XML and it won't matter.
>>
>>>I am attempting to integrate my VFP P.O.S. with Magento an open source web cart. So far I have mee accessing the MySql database directly but I know the API functions should be quicker and safer. My current issue is with trying to translate the following example code :-S into something usable in VFP.
>>>
>>>$proxy = new SoapClient('http://magentohost/api/soap/?wsdl');
>>>$sessionId = $proxy->login('apiUser', 'apiKey');
>>>
>>>$newImage = array(
>>> 'file' => array(
>>> 'name' => 'file_name',
>>> 'content' => base64_encode(file_get_contents('product.jpg')),
>>> 'mime' => 'image/jpeg'
>>> ),
>>> 'label' => 'Cool Image Through Soap',
>>> 'position' => 2,
>>> 'types' => array('small_image'),
>>> 'exclude' => 0
>>>);
>>>
>>>$imageFilename = $proxy->call($sessionId, 'product_media.create', array('Sku', $newImage));
>>>
>>>
>>>var_dump($imageFilename);
>>>
>>>
>>>My attempt
>>>
>>>
>>>local cBitMap, cBitMap1
>>>cBitMap1=FILETOSTR(STORE.cpicdir-"\product\"-alltrim(positems.mainimage))
>>>cBitMap=STRCONV(cBitMap1,13)
>>>
>>>dimension picfile(3,2)AS ARRAY
>>>store "name" to picfile(1,1)
>>>store "aatestpicture.png" to picfile(1,2)
>>>store "content" to picfile(2,1)
>>>store cBitMap to picfile(2,2)
>>>store "mime" to picfile(3,1)
>>>store "image/png" to picfile(3,2)
>>>
>>>dimension typefile(1)
>>>store "small_image" to typefile
>>>
>>>dimension picarray(5,2)AS ARRAY
>>>store "file" to picarray(1,1)
>>>store picfile to picarray(1,2)
>>>store "label" to picarray(2,1)
>>>store "this is my test image" to picarray(2,2)
>>>store "position" to picarray(3,1)
>>>store 2 to picarray(3,2)
>>>store "types" to picarray(4,1)
>>>store typefile to picarray(4,2)
>>>store "exclude" to picarray(5,1)
>>>store 0 to picarray(5,2)
>>>
>>>dimension oArray(1,2) AS ARRAY
>>>store positems.cupcnumber to oArray(1,1)
>>>store picarray to oArray(1,2)
>>>
>>>
>>>LOCAL loMage_Api_Model_Server_HandlerPort AS "XML Web Service"
>>>* LOCAL loMage_Api_Model_Server_HandlerPort AS "MSSOAP.SoapClient30"
>>>* Do not remove or alter following line. It is used to support IntelliSense for your XML Web service.
>>>*__VFPWSDef__: loMage_Api_Model_Server_HandlerPort = http://www.fantasyfestival.com/api/soap/?wsdl , MagentoService , Mage_Api_Model_Server_HandlerPort
>>>LOCAL loException, lcErrorMsg, loWSHandler
>>>TRY
>>>	loWSHandler = NEWOBJECT("WSHandler",IIF(VERSION(2)=0,"",HOME()+"FFC\")+"_ws3client.vcx")
>>>	loMage_Api_Model_Server_HandlerPort = loWSHandler.SetupClient("http://www.fantasyfestival.com/api/soap/?wsdl", "MagentoService", "Mage_Api_Model_Server_HandlerPort")
>>>* Call your XML Web service here.  ex: leResult = loMage_Api_Model_Server_HandlerPort.SomeMethod()
>>>	sessionid = loMage_Api_Model_Server_HandlerPort.login("fanfest", "sk1ppy")
>>>	leResult2 = loMage_Api_Model_Server_HandlerPort.CALL(sessionid, "product_media.create", oArray)
>>>
>>>CATCH TO loException
>>>	lcErrorMsg="Error: "+TRANSFORM(loException.ERRORNO)+" - "+loException.MESSAGE
>>>	DO CASE
>>>	CASE VARTYPE(loMage_Api_Model_Server_HandlerPort)#"O"
>>>* Handle SOAP error connecting to web service
>>>	CASE !EMPTY(loMage_Api_Model_Server_HandlerPort.FaultCode)
>>>* Handle SOAP error calling method
>>>		lcErrorMsg=lcErrorMsg+CHR(13)+loMage_Api_Model_Server_HandlerPort.DETAIL
>>>	OTHERWISE
>>>* Handle other error
>>>	ENDCASE
>>>* Use for debugging purposes
>>>	MESSAGEBOX(lcErrorMsg)
>>>FINALLY
>>>ENDTRY
>>>
>>>
>>>It logs in just fine the I get the error box with "Error: 1429 - OLE IDispatch exception code 0 from ? : image is not specified.."
>>>All help would be greatly appreciated. :-U
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform