php - send/retrieve xml file to/from server cocos2d-x -


my app saves data needs onto xml file stored on device. when user opens app pulls xml file can keep saved data.

i want able upload xml file server, using php script get/post calls if possible. know how send , retrieve single variable values not sure how send file, xml file.

am able use cocos2d httprequest/httpclient classes achieve this? or there better way.

thanks

i'm unfamiliar cocos2d, website has example of transferring file via post request (which better method transferring data such xml).

from cocos3d-x.org wiki:

cocos2d::network::httprequest* request = new cocos2d::network::httprequest(); request->seturl("http://www.httpbin.org/post"); request->setrequesttype(cocos2d::network::httprequest::type::post); request->setresponsecallback( cc_callback_2(httpclienttest::onhttprequestcompleted, this) );  // write post data const char* postdata = "visitor=cocos2d&testsuite=extensions test/networktest"; request->setrequestdata(postdata, strlen(postdata));  request->settag("post test1"); cocos2d::network::httpclient::getinstance()->send(request); request->release(); 

in example they're using postdata string data; you'll want replace xml contents.

in addition should include these standard headers:

  • content-type: application/xml; charset=utf-8 indicate type of data , it's encoding
  • content-length: 12389128 show length, in bytes, of attached data

you explore basic compression, should shrink xml.


Comments

Popular posts from this blog

1111. appearing after print sequence - php -

java - WARN : org.springframework.web.servlet.PageNotFound - No mapping found for HTTP request with URI [/board/] in DispatcherServlet with name 'appServlet' -

Ruby on Rails, ActiveRecord, Postgres, UTF-8 and ASCII-8BIT encodings -