Jump to content

dmmd01

New Members
  • Posts

    7
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

dmmd01's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Is there a way that I could have curl or some other operation print out to my screen or another file what was also sent to the http post? I'd like to be able to see the exact output to know that it is being sent correctly.
  2. Excellent, now we are getting somewhere... I replaced as you said, and when I accessed the test.php file, I got the following error: Curl error: SSL certificate problem, verify that the CA cert is OK. Details: error:14090086:SSL routines:SSL3_GET_SERVER_CERTIFICATE:certificate verify failed I did some research, and found that a workaround for this is to add the following before curl_exec(): curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); When I added that bit, I now get "Operation completed without any errors" --- I'm guessing that means the curl is working, but unfortunately I'm still not seeing any signs that the xml api is receiving this information. If everything is reaching the API, then I'm very confused why a session with that APP isn't being initiated. What else can I do to test this?
  3. When I place your if/else above the $ch = curl_init() I get notice that the Operation completed without errors... If I place the if/else below the curl_close() I get "Curl error:" Where should it be placed? If it is executing properly, I'm doubly confused because there is no response from my XMLAPI.
  4. I feel like I must be getting closer, but am just not there yet. I created my test.php file that is "exactly" as shown below. I tried a few test curl examples I found on the web to ensure that curl is working, and they all worked fine. When I use my browser and go to test.php with the code below, all I get is a blank screen... How can I know if the information is being sent correctly? Theoretically, when this information is passed, it should yield a response from XML API causing me to be logged in and open up the main page of that remote site. I didn't write the API so that code should be fine! I'll deal with the onclick execution once I can just get the code to work correctly. What can I do to check this code for mistakes? <?php $xml_data ='<xml-fragment xmlns:vp="http://myhost">'. '<vp:vprequest>'. '<query>authenticateUser</query>'. '</vp:vprequest>'. '<vp:vpuser>'. '<username>username</username>'. '<password>password</password>'. '<userid/>'. '<firstname/>'. '<lastname/>'. '<useremail/>'. '<assignedRoles>'. '<roleDef/>'. '</assignedRoles>'. '</vp:vpuser>'. '<vportal>'. '<vportal_id>1</vportal_id>'. '</vportal>'. '</xml-fragment>'; $post_data = 'xml_data = '.$xml_data; $URL = "https://myhost/xmlapi"; $ch = curl_init($URL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml')); curl_setopt($ch, CURLOPT_POSTFIELDS, "$post_data"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); ?>
  5. Alright, I think you've got me going in the right direction... I've scraped together the following code... Does it make sense? If so, how do I execute the code by means of an onclick of an image in a page? Again, thank you! <?php $xml_data ='<xml-fragment xmlns:vp="http://myhost.com/somedirectory">'. '<vp:vprequest>'. '<query>authenticateUser</query>'. '</vp:vprequest>'. '<vp:vpuser>'. '<username>$username</username>'. '<password>$password</password>'. '<userid/>'. '<firstname/>'. '<lastname/>'. '<useremail/>'. '<assignedRoles>'. '<roleDef/>'. '</assignedRoles>'. '</vp:vpuser>'. '<vportal>'. '<vportal_id>1</vportal_id>'. '</vportal>'. '</xml-fragment>'; $URL = "https://myhost.com/xmlapi"; $ch = curl_init($URL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/xml')); curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); $output = curl_exec($ch); curl_close($ch); ?>
  6. JL - thank you for responding. I have never used curl, but am reading about it now. I was able to find that I have curl installed on my host, so that is a start. Can you point me to a page with sample code on how something like what I am trying to do is accomplished? I'm using PHP 5.3.2 and curl 7.1.15 Again, thank you!
  7. I'm new to PHP, XML, and web development in general, so please bear with me... I'm working in a PHP environment and need to send user credentials $username and $password in XML via a HTTP post. Does that even make sense? Let me explain: I have already successfully used a method of capturing credentials, and they can be called by the use of $username and $password. I need to pass these on to an XML web service on another domain, but they need to be included in a larger piece of XML. To top it all off, I need this process to occur only when an image in a page is clicked. Here is the XML that needs to be sent (except that $username and $password are my strings from above): <xml-fragment xmlns:vp="http://my.host.com/somedirectory"> <vp:vprequest> <query>authenticateUser</query> </vp:vprequest> <vp:vpuser> <username>$username</username> <password>$password</password> <userid/> <firstname/> <lastname/> <useremail/> <assignedRoles> <roleDef/> </assignedRoles> </vp:vpuser> <vportal> <vportal_id>1</vportal_id> </vportal> </xml-fragment> I need to send it to: https://my.host.com/xmlwebapp Anything sending to the XML Web App must pass their XML data with the content type set to application/xml. I'm confused with how I should be sending this. I believe that the XML APP can receive HTTP POST, but I don't know how to write that code into PHP and then have it send it all as XML. Any help would be appreciated! Thank you!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.