hoangthi Posted November 17, 2013 Share Posted November 17, 2013 The service says that: Requests should be sent to: https://w3s.webmoney.ru/asp/XMLTrans.asp Method: POST and it is Request format: <w3s.request> <reqn></reqn> <wmid></wmid> <sign></sign> <trans> <tranid></tranid> <pursesrc></pursesrc> <pursedest></pursedest> <amount></amount> <period></period> <pcode></pcode> <desc></desc> <wminvid></wminvid> <onlyauth></onlyauth> </trans> </w3s.request>so, How can I do Link to comment https://forums.phpfreaks.com/topic/283987-how-to-post-a-xml-content-to-a-url/ Share on other sites More sharing options...
requinix Posted November 17, 2013 Share Posted November 17, 2013 cURL is the easiest. Find a quick primer on it (it's not difficult to use) and pay attention to the CURLOPT_POSTFIELDS setting. Your code should look something like $curl = curl_init("https://w3s.webmoney.ru/asp/XMLTrans.asp"); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, "your xml here"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curl); curl_close($curl); Link to comment https://forums.phpfreaks.com/topic/283987-how-to-post-a-xml-content-to-a-url/#findComment-1458651 Share on other sites More sharing options...
hoangthi Posted November 17, 2013 Author Share Posted November 17, 2013 On 11/17/2013 at 1:14 PM, requinix said: cURL is the easiest. Find a quick primer on it (it's not difficult to use) and pay attention to the CURLOPT_POSTFIELDS setting. Your code should look something like $curl = curl_init("https://w3s.webmoney.ru/asp/XMLTrans.asp"); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, "your xml here"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); $response = curl_exec($curl); curl_close($curl); I did this, but Nothing happended Link to comment https://forums.phpfreaks.com/topic/283987-how-to-post-a-xml-content-to-a-url/#findComment-1458658 Share on other sites More sharing options...
MDCode Posted November 17, 2013 Share Posted November 17, 2013 In requinix's example, the returned response from that site is saved in the variable $response. Link to comment https://forums.phpfreaks.com/topic/283987-how-to-post-a-xml-content-to-a-url/#findComment-1458662 Share on other sites More sharing options...
hoangthi Posted November 17, 2013 Author Share Posted November 17, 2013 On 11/17/2013 at 3:41 PM, SocialCloud said: In requinix's example, the returned response from that site is saved in the variable $response. Yes, There is nothing in $response Link to comment https://forums.phpfreaks.com/topic/283987-how-to-post-a-xml-content-to-a-url/#findComment-1458678 Share on other sites More sharing options...
MDCode Posted November 17, 2013 Share Posted November 17, 2013 What does your cURL structure look like after adding your XML? Link to comment https://forums.phpfreaks.com/topic/283987-how-to-post-a-xml-content-to-a-url/#findComment-1458684 Share on other sites More sharing options...
hoangthi Posted November 18, 2013 Author Share Posted November 18, 2013 On 11/17/2013 at 6:44 PM, SocialCloud said: What does your cURL structure look like after adding your XML? Oh I used Requinix 's example: $curl = curl_init("https://w3s.webmoney.ru/asp/XMLTrans.asp"); curl_setopt($curl, CURLOPT_POST, true); curl_setopt($curl, CURLOPT_POSTFIELDS, "xmlfile.xml"); curl_setopt($curl, CURLOPT_RETURNTRANSFER, true); echo $response = curl_exec($curl); curl_close($curl); xmlfile.xml: <w3s.request> <reqn>123</reqn> <wmid>abc</wmid> <sign>123</sign> <trans> <tranid>123</tranid> <pursesrc>123</pursesrc> <pursedest>123</pursedest> <amount>12</amount> <period>123</period> <pcode>123</pcode> <desc>123</desc> <wminvid>123</wminvid> <onlyauthabc></onlyauth> </trans> </w3s.request> Link to comment https://forums.phpfreaks.com/topic/283987-how-to-post-a-xml-content-to-a-url/#findComment-1458727 Share on other sites More sharing options...
requinix Posted November 18, 2013 Share Posted November 18, 2013 "xmlfile.xml" is not XML. It is a filename. curl_setopt($curl, CURLOPT_POSTFIELDS, file_get_contents("xmlfile.xml")); Link to comment https://forums.phpfreaks.com/topic/283987-how-to-post-a-xml-content-to-a-url/#findComment-1458728 Share on other sites More sharing options...
hoangthi Posted November 18, 2013 Author Share Posted November 18, 2013 On 11/18/2013 at 4:13 AM, requinix said: "xmlfile.xml" is not XML. It is a filename. curl_setopt($curl, CURLOPT_POSTFIELDS, file_get_contents("xmlfile.xml")); I tried this but the response is still nothing Link to comment https://forums.phpfreaks.com/topic/283987-how-to-post-a-xml-content-to-a-url/#findComment-1458835 Share on other sites More sharing options...
MDCode Posted November 18, 2013 Share Posted November 18, 2013 Ignore. Link to comment https://forums.phpfreaks.com/topic/283987-how-to-post-a-xml-content-to-a-url/#findComment-1458850 Share on other sites More sharing options...
requinix Posted November 18, 2013 Share Posted November 18, 2013 I assume you've done something to try to troubleshoot what's wrong, and not just tell us it doesn't work and wait for an answer? What have you tried? Have you checked the HTTP response code, which involves curl_getinfo? Have you checked that you're sending the right XML? Have you done a View Source on the page to see if maybe, just maybe, you were outputting XML and so couldn't see the markup because the browser was pretending it was HTML? Link to comment https://forums.phpfreaks.com/topic/283987-how-to-post-a-xml-content-to-a-url/#findComment-1458854 Share on other sites More sharing options...
hoangthi Posted November 19, 2013 Author Share Posted November 19, 2013 On 11/18/2013 at 6:34 PM, requinix said: I assume you've done something to try to troubleshoot what's wrong, and not just tell us it doesn't work and wait for an answer? What have you tried? Have you checked the HTTP response code, which involves curl_getinfo? Have you checked that you're sending the right XML? Have you done a View Source on the page to see if maybe, just maybe, you were outputting XML and so couldn't see the markup because the browser was pretending it was HTML? of course I viewed the source, Nothing... I will try again! Link to comment https://forums.phpfreaks.com/topic/283987-how-to-post-a-xml-content-to-a-url/#findComment-1458994 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.