Jump to content

angelleye

Members
  • Posts

    44
  • Joined

  • Last visited

    Never

Everything posted by angelleye

  1. Seems to be working on the servers I'm playing with now. I don't know why I thought it seemed to take me to the actual document root instead of the site root in the past. I guess I'm good for now. Thanks!
  2. Ok, that makes sense. Can you provide any tip on how to get PHP to always refer to the site root no matter what server it's running from?
  3. I'm a little confused with the use of absolute paths in PHP. I've always used relative paths but it's becoming an issue with some of the apps I'm working with and absolute would solve the problem. The thing is, I'm getting different results in different places and I'm a little confused. With regular HTML I seem to be able to use / as the root of my site. So if I do the following... <img src="/images/name.jpg" /> That works fine no matter what page it's called from in the site and no matter what directory that page is in. I need to be able to do that same thing with PHP. Now, in my custom 404 page I have the following... if($AddressURL == 'http://www.domain.com/blog/files/filename.zip') { header('HTTP/1.1 301 Moved Permanently'); header('Location: /download/filename.zip'); exit(); } That actually works just fine. If I go to the /blog/files/filename.zip (which doesn't exist) in a web browser it winds up downloading the file at www.domain.com/download/filename.zip as expected. Now where I get confused is that include files don't seem to work like that with PHP. If I do this... require_once('/includes/config.php'); That winds up looking for an /includes folder all the way back at the local server root, not just the web root. so it's looking for /var/includes instead of /var/www/includes and of course that doesn't end up working. So, how come the include file paths work differently than regular HTML paths or header redirects in PHP? Is there any simple way I can always refer to the SITE root no matter what server it's running from? I've tried playing with $_SERVER['DOCUMENT_ROOT'] but it only seems to return the root of the current document, not the root of the whole site. So if I use it within a php file located in /var/www/includes/test.php it considers /includes the root which is not what I want. Any information would be greatly appreciated. Thanks!
  4. Updating your database is not recommend on your return page. There is no guarantee the user will return to the return page (even with auto-return enabled). You should use IPN https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_admin_IPNIntro instead, which is always guaranteed to take place. It's server to server communication, though, so it's a little bit tougher to setup. I created a solution that a lot of people are using. It's posted on PayPal's developer forum: https://www.x.com/thread/30664
  5. This should be real simple I just don't know how to do it. I'm using PayPal IPN to process order data. IPN is setup to automatically re-try the IPN if doesn't receive a 200 OK response back from the IPN script. In my solution, though, I'm actually storing any MySQL errors and notifying the site owner so the script actually does successfully complete and send a 200 OK back to PayPal, therefore, the IPN is not re-tried. I'd like to send a 500 (or anything other than 200) back to PayPal when this happens, but of course, the script still needs to run successfully. Is there a way I can use header() or anything to force a specific response code back? This way if it's simply a matter of MySQL timing out (which tends to happen on shared servers sometimes) PayPal's system will re-try and I won't have to enter it myself. Any information on this would be greatly appreciated. Thanks!
  6. You can specify a return_url in your html button code (as well as API requests) that will override anything you have set in your account profile. This way you can send dynamic return URL's with each payment instead of setting up a static URL in your profile. When using PayPal Standard, though, there is no guarantee the user will end up back at your site even with auto-return turned on. They could close the browser before the return happens. If you need to rely on this for updating a database, sending out email receipts, etc. you should use IPN and notify_url instead.
  7. Yes, the host header is needed because I'm hosting more than 1 site on the same IP address and the same port. That part is all working fine. I've figured out that when I comment out the doc_root in php.ini then PHP pages will indeed load on the sites, however, all of my relative links to includes like css, js, etc. aren't working when I do that. Apparently what I need is to specify separate php.ini files for each site, or specify multiple doc_root's in a single php.ini file. Possible..??
  8. I've got a test server setup at sandbox.mydomain.com on Win2k3 with IIS 6. I've got PHP installed on this server and it works great on the default web site in IIS. I've always had my client web sites under /client-sites on my default web site. The problem with this is that when my clients are using things like ./ in their links it goes back up to my actual root instead of their site's root (ie. sandbox.mydomain.com/client-sites/site-name). To fix this I've gone ahead and created additional A records in my DNS to point other sub-domains to my test server (ie. client.mydomain.com) and then I created a new site in IIS and applied the host header value of client.mydomain.com. With that I can successfully browse the client's site via http://client.mydomain.com, however, PHP does not work on these additional sites. It still works great on my default site in IIS, just not on any of the extra sites I add this way. I can browse HTML files, txt files, images, etc. just fine but anything PHP just gives me page not found. Any information on how I can make PHP work with ALL sites in IIS instead of just the default would be greatly appreciated. Thanks!
  9. I've installed PHP on Win2k3 a number of times and I've never had a problem. This particular server is driving me nuts. I cannot figure out why PHP won't work on this IIS install. Here's what I've done. 1) Download the ZIP package of PHP for manual installation 2) Extract the files to C:\PHP 3) Edit php.ini in the following ways... - include_path = ".;c:\php\includes" - doc_root = "W:\" - extension_dir = "C:\PHP\ext" -cgi.force_redirect = 0 4) Added PHP to the Web Service Extensions in IIS and set it to the php5isapi.dll file. 5) Added C:\PHP to the Path variable under the system's Enviornment Variables and I also added a new variable called PHPRC with C:\PHP\php.ini 6) Reboot the server This usually takes care of everything and I can move on to MySQL install and then start putting my apps up. Not in this case. I'm getting 404 error any time I try and browse a PHP file on this web server. If I simply change that file to .txt instead of .php then it loads fine. Switch it back to .php and I get a 404 again. I've followed all of the steps here to try and troubleshoot (http://www.verysimple.com/blog/2008/01/05/php-on-windows-2003-iis-6-displays-404-page-not-found/) and nothing is working. I also tried running the file (which has nothing but echo 'test'; in it right now) from a command line and that is working just fine, so PHP itself is indeed functioning on the server. It's just that it's not communicating with IIS for some reason. I double checked that I added my Web Service Extension and it's in there as PHP with php5isapi.dll and it's set to Allowed. I've also compared this to my own working test server here and the only difference I can see is that they have MS SharePoint and FrontPage extensions installed and I've never had that in the mix. It's created an additional web site and an additional application pool apart from the defaults. I have no idea if that's causing any of my problems but it's the only thing different I see from all of the servers I've done this on in the past. Any information on how I can fix this would be greatly appreciated. Thanks!
  10. On my phpinfo it shows log_errors is On but then when I go to error_log to try and see the path for the actual file so I can look at it I see 'no value'. I don't see anything in the php.ini about setting an actual file. What am I missing? I've got some errors happening on a script that gets hit behind-the-scenes (PayPal Notification system) and I see in my web logs that I'm getting a 500 error but I can't see the actual error code or messages getting returned. Any information would be greatly appreciated. Thanks!
  11. Looks like that's working. I could have sworn I tried that but I guess not. Thanks!!!
  12. I've got some scripts setup that have if statements inside them but I like to avoid using else unless I really need it. For example, something like... if(count($Errors) > 0) { $_SESSION['Errors'] = $Errors; header("Location: error.php"); } // if no error go ahead and move on. No need for else because if there is error it redirects away from here anyway. That idea seems to work fine for me as long as I don't end the whole page with a redirect. An example of when this happens is when I've got a script that's adding all of the order info to a DB and at the end redirects to a successful/receipt page. The very last thing on this script would be a redirection. The problem is that if I have something like the following... if(count($Errors) > 0) { $_SESSION['Errors'] = $Errors; header("Location: error.php"); } // no errors so call was successful, redirect to paypal header("Location: payment-complete.php"); and there are indeed errors in $Errors it doesn't redirect to the error.php page. I end up at my payment-complete.php page with errors because of course it doesn't get all of the data it expects since the error occurred and it should ahve never reached that page to begin with. What's interesting is that if I remove the redirect at the very bottom where I assume everything works and just do something like echo a line.. if(count($Errors) > 0) { $_SESSION['Errors'] = $Errors; header("Location: error.php"); } // no errors so call was successful, redirect to paypal echo 'it worked'; Then it does indeed redirect to my error.php as it should when errors occur. So it seems like the entire PHP script is getting parsed and if there are no PHP failures then the final header() just loads regardless. But if I don't have a header() outside of my if statements then they will indeed work inside those if statements. I hope I explained that well enough. I'm confused about why it's happening. Any information on this would be greatly appreciated. Thanks!
  13. This is running on my test server and I've already got that set to show all. I'm not getting any errors or warnings.
  14. Hmmm...looks like a great source but I'm not having any luck. Following the instructions and using that FireFox tool I see that when I login it actually seems to go through a few pages. Here's what it gave me.. https://developer.paypal.com/cgi-bin/devscr?__track=_logout:login/main:_login-submit POST /cgi-bin/devscr?__track=_logout:login/main:_login-submit HTTP/1.1 Host: developer.paypal.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: https://developer.paypal.com/cgi-bin/devscr?cmd=_logout Cookie: homepage=3; upct=24; KHcl0EuY7AKSMgfvHl7J5E7hPtK=bFrgcM30Gb-2b3E85K4SiHyEzsMZeRVIqxjlur44o74QGXZnvTnHGme_QggT-eQFT34cVqPLl1OhGdE_; cookie_srd_optin=true; s_pers=%20s_favsn_paypalglobal_1%3D9856380030122%7C1505841661312%3B; cookie_check=yes; login_email=andrew%40angelleye.com; INSIDE_SEARCH_PARAMS=2%3bUS%3ben_US%3bAmerica%2fLos_Angeles; navlns=0; LANG=en_US%3bUS; nMjq0zk0-yCYE_iBONIGREETTNW=; dev_login_email=andrew%40angelleye.com; wwp_ClJZM3hWN6BNtpFD0LimhmC=; __login_track=SJZDNH8fctvqVf3Kf226tZyuuqtefbzza2dCsGL5wgEnnp25shrKG7LFry0 Content-Type: application/x-www-form-urlencoded Content-Length: 116 cmd=_login-submit&login_cmd=&login_params=&login_email=LOGIN_EMAIL&login_password=LOGIN_PW&submit=Log+In HTTP/1.x 302 Found Date: Wed, 09 Apr 2008 05:21:28 GMT Server: Apache/1.3.27 (Unix) mod_ssl/2.8.12 OpenSSL/0.9.7a mod_fastcgi/2.4.2 PHP/4.3.2 Cache-Control: private Expires: Thu, 05 Jan 1995 22:00:00 GMT Pragma: no-cache Set-Cookie: nMjq0zk0-yCYE_iBONIGREETTNW=Jpm8RBa7sT64hIbo8v2itdfrzX6QWIO7bstdDvYj-dzgOOwis787txlMhLTiBzIPKo7tuLE2flqqRVTd3ISWJF63NnC; expires=Sat, 06-Sep-2008 05:21:31 GMT; path=/; domain=.paypal.com Set-Cookie: dev_login_email=andrew%40angelleye.com; expires=Mon, 06-Oct-2008 05:21:31 GMT; path=/; domain=.paypal.com Set-Cookie: wwp_ClJZM3hWN6BNtpFD0LimhmC=; path=/; domain=.paypal.com Set-Cookie: __login_track=SJZDNH8fctvqVf3Kf226tZyuuqtefbzza2dCsGL5wgEnnp25shrKG7LFry0; path=/; domain=.paypal.com Location: https://developer.paypal.com/cgi-bin/devscr?cmd=_login-processing&login_cmd=_login-done&login_access=0 Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=iso-8859-1 ---------------------------------------------------------- https://developer.paypal.com/cgi-bin/devscr?cmd=_login-processing&login_cmd=_login-done&login_access=0 GET /cgi-bin/devscr?cmd=_login-processing&login_cmd=_login-done&login_access=0 HTTP/1.1 Host: developer.paypal.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: https://developer.paypal.com/cgi-bin/devscr?cmd=_logout Cookie: homepage=3; upct=24; KHcl0EuY7AKSMgfvHl7J5E7hPtK=bFrgcM30Gb-2b3E85K4SiHyEzsMZeRVIqxjlur44o74QGXZnvTnHGme_QggT-eQFT34cVqPLl1OhGdE_; cookie_srd_optin=true; s_pers=%20s_favsn_paypalglobal_1%3D9856380030122%7C1505841661312%3B; cookie_check=yes; login_email=LOGIN_EMAIL; INSIDE_SEARCH_PARAMS=2%3bUS%3ben_US%3bAmerica%2fLos_Angeles; navlns=0; LANG=en_US%3bUS; nMjq0zk0-yCYE_iBONIGREETTNW=Jpm8RBa7sT64hIbo8v2itdfrzX6QWIO7bstdDvYj-dzgOOwis787txlMhLTiBzIPKo7tuLE2flqqRVTd3ISWJF63NnC; dev_login_email=LOGIN_EMAIL; wwp_ClJZM3hWN6BNtpFD0LimhmC=; __login_track=SJZDNH8fctvqVf3Kf226tZyuuqtefbzza2dCsGL5wgEnnp25shrKG7LFry0 HTTP/1.x 200 OK Date: Wed, 09 Apr 2008 05:21:31 GMT Server: Apache/1.3.27 (Unix) mod_ssl/2.8.12 OpenSSL/0.9.7a mod_fastcgi/2.4.2 PHP/4.3.2 Cache-Control: private Expires: Thu, 05 Jan 1995 22:00:00 GMT Pragma: no-cache Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8 ---------------------------------------------------------- https://developer.paypal.com/cgi-bin/devscr?cmd=_login-done&login_access=0 GET /cgi-bin/devscr?cmd=_login-done&login_access=0 HTTP/1.1 Host: developer.paypal.com User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13 Accept: text/xml,application/xml,application/xhtml+xml,text/html;q=0.9,text/plain;q=0.8,image/png,*/*;q=0.5 Accept-Language: en-us,en;q=0.5 Accept-Encoding: gzip,deflate Accept-Charset: ISO-8859-1,utf-8;q=0.7,*;q=0.7 Keep-Alive: 300 Connection: keep-alive Referer: https://developer.paypal.com/cgi-bin/devscr?cmd=_login-processing&login_cmd=_login-done&login_access=0 Cookie: homepage=3; upct=24; KHcl0EuY7AKSMgfvHl7J5E7hPtK=bFrgcM30Gb-2b3E85K4SiHyEzsMZeRVIqxjlur44o74QGXZnvTnHGme_QggT-eQFT34cVqPLl1OhGdE_; cookie_srd_optin=true; s_pers=%20s_favsn_paypalglobal_1%3D9856380030122%7C1505841661312%3B; cookie_check=yes; login_email=LOGIN_EMAIL; INSIDE_SEARCH_PARAMS=2%3bUS%3ben_US%3bAmerica%2fLos_Angeles; navlns=0; LANG=en_US%3bUS; nMjq0zk0-yCYE_iBONIGREETTNW=Jpm8RBa7sT64hIbo8v2itdfrzX6QWIO7bstdDvYj-dzgOOwis787txlMhLTiBzIPKo7tuLE2flqqRVTd3ISWJF63NnC; dev_login_email=LOGIN_EMAIL; wwp_ClJZM3hWN6BNtpFD0LimhmC=; __login_track=SJZDNH8fctvqVf3Kf226tZyuuqtefbzza2dCsGL5wgEnnp25shrKG7LFry0 HTTP/1.x 200 OK Date: Wed, 09 Apr 2008 05:21:33 GMT Server: Apache/1.3.27 (Unix) mod_ssl/2.8.12 OpenSSL/0.9.7a mod_fastcgi/2.4.2 PHP/4.3.2 Cache-Control: must-revalidate, proxy-revalidate, no-cache Set-Cookie: nMjq0zk0-yCYE_iBONIGREETTNW=8qM5LB9CpXGBE5a_I5Rhcbxm4Gh5sb9jkHZIp48LnFbNJ_aBcwM3cLz6hMWmXxvggy0dck9TI_dy2xGNAa9b_KE9Nme; expires=Sat, 06-Sep-2008 05:21:34 GMT; path=/; domain=.paypal.com Connection: close Transfer-Encoding: chunked Content-Type: text/html; charset=UTF-8 ---------------------------------------------------------- So based off that and trying to go off this sample I've got the following: <?php include_once("../includes/Functions.php"); $PayPalDevUsername = "LOGIN_EMAIL"; $PayPalDevPassword = "LOGIN_PASSWORD"; $PayPalDevLoginURL = "https://developer.paypal.com/cgi-bin/devscr?__track=_home:login/main:_login-submit"; $PayPalDevLoginCredentials = "cmd=_login-submit&login_cmd=&login_params=&login_email=" . $PayPalDevUsername . "&login_password=" . $PayPalDevPassword . "&submit=Log+In"; $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt"); curl_setopt($ch, CURLOPT_URL, $PayPalDevLoginURL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_REFERER, "https://developer.paypal.com/devscr?cmd=_logout"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, $PayPalDevLoginCredentials); $res = curl_exec($ch); curl_close($ch); $PayPalDevLoginURL = "https://developer.paypal.com/cgi-bin/devscr?cmd=_login-processing&login_cmd=_login-done&login_access=0"; $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt"); curl_setopt($ch, CURLOPT_URL, $PayPalDevLoginURL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_REFERER, "https://developer.paypal.com/devscr?cmd=_logout"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, ""); $res = curl_exec($ch); curl_close($ch); $PayPalDevLoginURL = "https://developer.paypal.com/cgi-bin/devscr?cmd=_login-done&login_access=0"; $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "cookies.txt"); curl_setopt($ch, CURLOPT_COOKIEFILE, "cookies.txt"); curl_setopt($ch, CURLOPT_URL, $PayPalDevLoginURL); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt($ch, CURLOPT_REFERER, "Referer: https://developer.paypal.com/cgi-bin/devscr?cmd=_login-processing&login_cmd=_login-done&login_access=0"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_POSTFIELDS, ""); $res = curl_exec($ch); curl_close($ch); ?> When I run that I get a blank white page and I still can't access the PayPal sandbox. Any ideas??
  15. Well, actually, I use curl in my current scripts to make XML/SOAP calls to the PayPal Web Services. I just include credentials in the SOAP requests, though, so I haven't had to dig too deep into actual curl headers. Can you possibly refer me to a good example of this being done? I'm having some trouble finding anything for some reason.
  16. I shouldn't have said test, I should have said demo. Of course I test it for them, and it's not a big problem for me. I can't allow them to demo it themselves, though.
  17. You just need to loop through them all. First, split them based on the comma. That will give you an array of all of the values. Then loop the array to do any SQL stuff within the loop. This should give you a good idea... <?php $SessionVarSplit = explode(',', $_SESSION['sessionvar']); foreach($SessionVarSplit as $ID) { $query = "SELECT * FROM books WHERE id = '" . $ID . "'"; // display records and print page } ?>
  18. I work a lot with PayPal Web Services. When you test applications using PayPal's test servers you must first log into your account at http://developer.paypal.com. Only then will their test accounts work for you. This can be a real pain when trying to have clients test solutions you've developed for them, or even just the fact that you have to do that everytime. Kind of annoying. Is there any way I could login to the site as a first step in my test pages so I didn't actually have to manually do it? Any information on this would be greatly appreciated. Thanks!
  19. Good point. I ran phpinfo() and found the true full path of my directory on this web host. Using that I was able to figure out the path to the new folder I created in my {home} directory that was located outside of the web root.
  20. My local test servers are Windows based. Many of my applications use web services that require credentials for authenticating my API access (eBay, PayPal, etc.) On my test servers I've stored a credentials.xml file outside of the web site root. Then, within my PHP scripts I can do something like this: // Open file outside of web root which contains PayPal credentials. This is for security purposes. $ConfigFilePath = "D:\WebNonPublic\credentials.xml"; if(!$PayPalCredentials = simplexml_load_file($ConfigFilePath)) exit("There was an error opening the credentials file"); //set the API credentials based on sandbox boolean passed if(!$Sandbox) { $APIUsername = $PayPalCredentials -> Production -> Username; $APIPassword = $PayPalCredentials -> Production -> Password; $APISignature = $PayPalCredentials -> Production -> Signature; $EndPointURL = $PayPalCredentials -> Production -> EndPointURL; } else { $APIUsername = $PayPalCredentials -> Sandbox -> Username; $APIPassword = $PayPalCredentials -> Sandbox -> Password; $APISignature = $PayPalCredentials -> Sandbox-> Signature;; $EndPointURL = $PayPalCredentials -> Sandbox-> EndPointURL;; } That works beautifully and then if somebody decides to download my entire web site they can't see any of my credentials. My live web host that I'm using is a Linux host with Apache. I'm not very experienced administering this at all. I can FTP into my site root and I can see that the public stuff goes into /www and there are lots of files outside of that like .htaccess and many others. I tried placing my credentials.xml in the same place .htaccess is but then I can't seem to get to it. I tried ./credentials.xml, and then I also tried the normal ../../credentials.xml. I added an extra ../ in hopes it would reach up to the level above /www and be able to find it. I can't get anything to work, though. Any information on how I can accomplish this would be greatly appreciated. Thanks!
  21. I'm working with PayPal's API, specifically the Express Checkout portion. I've very experienced with it, but not as experienced with PHP. The first call you make during Express Checkout has the option to send <Custom> and <InvoiceID>. If you send it they will be returned in the details response later on (the second call in the process.) I have functions setup to handle each call. I'm actually treating their SOAP API just like XML over HTTP rather than working with .wsdl files because I simply haven't figured that out yet. Anyway, I make the call and then I parse the response using DOMDocument() and getElementsByTagName(). The problem occurs when <Custom> and <InvoiceID> don't get sent originally and they don't come back later. I wind up with notices: Trying to get property of non-object. Here's a look at the SOAP/XML response I'm working with.. <?xml version="1.0" encoding="UTF-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:SOAP-ENC="http://schemas.xmlsoap.org/soap/encoding/" xmlns:xsi="http://www.w3.org/1999/XMLSchema-instance" xmlns:xsd="http://www.w3.org/1999/XMLSchema" xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:cc="urn:ebay:apis:CoreComponentTypes" xmlns:wsu="http://schemas.xmlsoap.org/ws/2002/07/utility" xmlns:saml="urn:oasis:names:tc:SAML:1.0:assertion" xmlns:ds="http://www.w3.org/2000/09/xmldsig#" xmlns:market="urn:ebay:apis:Market" xmlns:auction="urn:ebay:apis:Auction" xmlns:sizeship="urn:ebay:api:PayPalAPI/sizeship.xsd" xmlns:ship="urn:ebay:apis:ship" xmlns:skype="urn:ebay:apis:skype" xmlns:wsse="http://schemas.xmlsoap.org/ws/2002/12/secext" xmlns:ebl="urn:ebay:apis:eBLBaseComponents" xmlns:ns="urn:ebay:api:PayPalAPI"> <SOAP-ENV:Header> <Security xmlns="http://schemas.xmlsoap.org/ws/2002/12/secext" xsi:type="wsse:SecurityType"></Security> <RequesterCredentials xmlns="urn:ebay:api:PayPalAPI" xsi:type="ebl:CustomSecurityHeaderType"> <Credentials xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:UserIdPasswordType"> <Username xsi:type="xs:string"></Username> <Password xsi:type="xs:string"></Password> <Signature xsi:type="xs:string"></Signature> <Subject xsi:type="xs:string"></Subject> </Credentials> </RequesterCredentials> </SOAP-ENV:Header> <SOAP-ENV:Body id="_0"> <GetExpressCheckoutDetailsResponse xmlns="urn:ebay:api:PayPalAPI"> <Timestamp xmlns="urn:ebay:apis:eBLBaseComponents">2008-02-17T03:08:54Z</Timestamp> <Ack xmlns="urn:ebay:apis:eBLBaseComponents">Success</Ack> <CorrelationID xmlns="urn:ebay:apis:eBLBaseComponents">bc959a8774e4b</CorrelationID> <Version xmlns="urn:ebay:apis:eBLBaseComponents">50.000000</Version> <Build xmlns="urn:ebay:apis:eBLBaseComponents">512684</Build> <GetExpressCheckoutDetailsResponseDetails xmlns="urn:ebay:apis:eBLBaseComponents" xsi:type="ebl:GetExpressCheckoutDetailsResponseDetailsType"> <Token xsi:type="ebl:ExpressCheckoutTokenType">EC-07T88228A7173890V</Token> <PayerInfo xsi:type="ebl:PayerInfoType"> <Payer xsi:type="ebl:EmailAddressType">drew_angell@yahoo.com</Payer> <PayerID xsi:type="ebl:UserIDType">USXPZMPA94YQ6</PayerID> <PayerStatus xsi:type="ebl:PayPalUserStatusCodeType">verified</PayerStatus> <PayerName xsi:type="ebl:PersonNameType"> <Salutation xmlns="urn:ebay:apis:eBLBaseComponents"></Salutation> <FirstName xmlns="urn:ebay:apis:eBLBaseComponents">Drew</FirstName> <MiddleName xmlns="urn:ebay:apis:eBLBaseComponents"></MiddleName> <LastName xmlns="urn:ebay:apis:eBLBaseComponents">Angell</LastName> <Suffix xmlns="urn:ebay:apis:eBLBaseComponents"></Suffix> </PayerName> <PayerCountry xsi:type="ebl:CountryCodeType">US</PayerCountry> <PayerBusiness xsi:type="xs:string"></PayerBusiness> <Address xsi:type="ebl:AddressType"> <Name xsi:type="xs:string">Drew Angell</Name> <Street1 xsi:type="xs:string">34234 E. 50th St.</Street1> <Street2 xsi:type="xs:string"></Street2> <CityName xsi:type="xs:string">Kansas City</CityName> <StateOrProvince xsi:type="xs:string">MO</StateOrProvince> <Country xsi:type="ebl:CountryCodeType">US</Country> <CountryName></CountryName> <PostalCode xsi:type="xs:string">64111</PostalCode> <AddressOwner xsi:type="ebl:AddressOwnerCodeType">PayPal</AddressOwner> <AddressStatus xsi:type="ebl:AddressStatusCodeType">Confirmed</AddressStatus> </Address> <ContactPhone xsi:type="xs:string"></ContactPhone> </PayerInfo> <BillingAgreementAcceptedStatus>false</BillingAgreementAcceptedStatus> </GetExpressCheckoutDetailsResponseDetails> </GetExpressCheckoutDetailsResponse> </SOAP-ENV:Body> </SOAP-ENV:Envelope> Here is how I'm parsing the data, which I was thinking would handle when the element didn't exist... $XMLDOM = new DOMDocument(); $XMLDOM -> loadXML($SOAPResponse); $Custom = $XMLDOM -> getElementsByTagName("Custom"); if(isset($Custom)) $Custom = $Custom -> item(0) -> nodeValue; else $Custom = ""; $InvoiceID = $XMLDOM -> getElementsByTagName("InvoiceID"); if(isset($InvoiceID)) $InvoiceID = $InvoiceID -> item(0) -> nodeValue; else $InvoiceID = ""; The error is actually occurs on the line that uses ->item(0) -> nodeValue. So apparently $InvoiceID and $Custom are getting set (and passing the isset() check) but then that element isn't actually in the response data so it can't parse it. All of the rest of them are working beautifully as long as the element actually exists in the response, even if it's a blank element. Any information on how to do this correctly would be greatly appreciated. Thanks!
  22. I developed a PayPal solution for my client but I have PHP 5.2 installed on my development server. I made the mistake of assuming my client's host would also have PHP5. Of course, they're using PHP 4.4 so now all of my DOM code that parses XML responses does not work. I always have trouble understanding php.net for some reason. I tend to do better with tutorials/guides people write out and show lots of nice sample code. I can't seem to find anything like that for PHP 4 XML DOM besides php.net. I just don't follow it for some reason. Anyway, here is a short snippet of code that does not work in PHP 4 because I'm using PHP5 DOM instead of PHP4 XML DOM. If I could get some information ( or sample code would be great ) now how to convert this so it will work with PHP4 XML DOM then I think I can handle converting the rest of my stuff. $xmlDOM = new DOMDocument(); $xmlDOM -> loadXML($SOAPResponse); $xPath = new DOMXPath($xmlDOM); $xPath -> registerNamespace("pp", "urn:ebay:api:PayPalAPI"); $xPath -> registerNamespace("ebay", "urn:ebay:apis:eBLBaseComponents"); $FaultCode = $xmlDOM -> getElementsByTagName("faultcode"); if($FaultCode -> length > 0) { $FaultCode = $FaultCode -> item(0) -> nodeValue; $FaultString = $xmlDOM -> getElementsByTagName("faultstring"); $FaultString = $FaultString -> item(0) -> nodeValue; ?> </p> <table width="500" border="0" align="center" cellpadding="2" cellspacing="2"> <tr> <td width="129" align="right" valign="top"><strong>Fault Code:</strong></td> <td width="357" align="left" valign="top"><?php echo $FaultCode; ?> </td> </tr> <tr> <td align="right" valign="top"><strong>Fault Message:</strong></td> <td align="left" valign="top"><?php echo $FaultString; ?> </td> </tr> </table> <?php die(); } Any info would be greatly appreciated. Thanks!!
  23. I did have to register multiple namespaces and then I just use each one where necessary in the query. for instance $XPath -> query("//ns1:TransactionDetails/ns2:PayerInfo/ns2:PayerName/text()");
  24. I'm getting a little lost with namespaces in my XML responses from API's. I'm using DOM (DOMXPath) to parse the data out of it and before that works I have to either register the namespace in DOMXPath or strip the XML response of all the namespace information prior to loading it into DOM. I'd rather do it the correct way and use namespaces. Here's the thing. Consider the following XML: http://www.angelleye.com/phpTraining/XML_Parsing_Samples/fmresult.xml That has the xmlns="http://www.filemaker.com/xml/fmresultset" associated with it. As such, when I load this into DOM I have the following: $xmlDom = new DOMDocument(); $xmlDom -> loadXML($xmlResponse); $xmlDomXPath = new DOMXPath($xmlDom); $xmlDomXPath -> registerNamespace("fm", "http://www.filemaker.com/xml/fmresultset"); $records = $xmlDomXPath -> query("/fm:fmresultset/fm:resultset/fm:record"); $recordCount = $records -> length; //etc. That works great. I just add fm: to the front of all the XPath elements as shown from there on and it works just fine. Now consider the following XML: http://www.angelleye.com/angelleyephp/eBayApps/1DD3523773371373B.xml That is full of namespaces and I can't seem to figure out what I need to do in order to be able to parse using XPath in the same manner. Do I need to register ALL of those namespaces? How do I know which namespace to use to grab which element values..?? Any information on this would be greatly appreciated. I've looked into PHP SOAP (since this particular XML is indeed a SOAP response) but everything I see converts it to a PHP array and I'd rather just work with XPath. Thanks!
×
×
  • 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.