Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 8 of 8

Thread: PHP_XML_Socket

  1. #1
    New Coder
    Join Date
    Apr 2008
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts

    PHP_XML_Socket

    Hi im having a bit of problem with some code, im really unsure how its meant to be designed to work, this is just a simple tutorial which they have put in a few different files, of which i dont even know how they include each other.

    Its just meant to bring up some test data, but i just get a configured incorrectly error.

    Heres code 1:
    PHP Code:
    <?php
      
    function get_response($res) {
        
    $size_packed fread($res4);
        if(
    strlen($size_packed) == 0) return;
        
    $size unpack("N"$size_packed);
        
    // This works around PHP's fread() capping at 8192 bytes
        
    $out "";
        
    $last "";
        for(
    $s $size[1]-4$s>0$s-=strlen($last)) {
          
    $last fread($this->res$s);
          
    $out.=$last;
        }
        return 
    $out;
      }
      
      
    $res fsockopen("tls://customer.heartinternet.co.uk"1701);
      
      
    get_response($res);
      
      
    fwrite($respack("N"strlen($output)+4) . $output);
      
      
    $content get_response($res);
      
        
    $parser xml_parser_create();
        
    xml_parser_set_option($parserXML_OPTION_CASE_FOLDING0);
        
    xml_parser_set_option($parserXML_OPTION_SKIP_WHITE1);
        
    xml_parse_into_struct($parser$content$result);
      
    //  print $parser."a";
      
    } else {
        
    // Error handling
      
    }

      
    fclose($res); // When you're finished. 
    ?>
    Code2:
    PHP Code:
      $namespace "urn:ietf:params:xml:ns:epp-1.0";
      
    $doc = new DOMDocument(); $l $doc;
      
    $c $doc->createElementNS($namespace'epp');
      
    $l->appendChild($c); $l $c;
        
    $c $doc->createElementNS($namespace'hello');
        
    $l->appendChild($c);
      
    $l $l->parentNode
      
    $output $doc->saveXML(); 
    Code3:
    Code:
     Array
      (
          [0] => Array
              (
                  [tag] => epp
                  [type] => open
                  [level] => 1
                  [attributes] => Array
                      (
                          [xmlns] => urn:ietf:params:xml:ns:epp-1.0
                      )
      
              )
      
          [1] => Array
              (
                  [tag] => greeting
                  [type] => open
                  [level] => 2
              )
      
          [2] => Array
              (
                  [tag] => svID
                  [type] => complete
                  [level] => 3
                  [value] => Heart Internet Test API Server
              )
      
          [3] => Array
              (
                  [tag] => svDate
                  [type] => complete
                  [level] => 3
                  [value] => 2010-08-17T12:34:53Z
              )
      
          [4] => Array
              (
                  [tag] => svcMenu
                  [type] => open
                  [level] => 3
              )
      
          [5] => Array
              (
                  [tag] => version
                  [type] => complete
                  [level] => 4
                  [value] => 1.0
              )
      
          [6] => Array
              (
                  [tag] => lang
                  [type] => complete
                  [level] => 4
                  [value] => en-GB
              )
      
          [7] => Array
              (
                  [tag] => objURI
                  [type] => complete
                  [level] => 4
                  [value] => urn:ietf:params:xml:ns:contact-1.0
              )
      
          [8] => Array
              (
                  [tag] => objURI
                  [type] => complete
                  [level] => 4
                  [value] => urn:ietf:params:xml:ns:domain-1.0
              )
      
          [9] => Array
              (
                  [tag] => objURI
                  [type] => complete
                  [level] => 4
                  [value] => http://www.heartinternet.co.uk/whapi/database-2.0
              )
      
          [10] => Array
              (
                  [tag] => objURI
                  [type] => complete
                  [level] => 4
                  [value] => http://www.heartinternet.co.uk/whapi/mailbox-2.0
              )
      
          [11] => Array
              (
                  [tag] => objURI
                  [type] => complete
                  [level] => 4
                  [value] => http://www.heartinternet.co.uk/whapi/null-2.0
              )
      
          [12] => Array
              (
                  [tag] => objURI
                  [type] => complete
                  [level] => 4
                  [value] => http://www.heartinternet.co.uk/whapi/package-2.0
              )
      
          [13] => Array
              (
                  [tag] => objURI
                  [type] => complete
                  [level] => 4
                  [value] => http://www.heartinternet.co.uk/whapi/server-2.0
              )
      
          [14] => Array
              (
                  [tag] => objURI
                  [type] => complete
                  [level] => 4
                  [value] => http://www.heartinternet.co.uk/whapi/support-2.0
              )
      
          [15] => Array
              (
                  [tag] => svcExtension
                  [type] => open
                  [level] => 4
              )
      
          [16] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-antivirus-2.0
              )
      
          [17] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-billing-2.0
              )
      
          [18] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-database-2.0
              )
      
          [19] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-dns-2.0
              )
      
          [20] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-domain-2.0
              )
      
          [21] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-contact-2.0
              )
      
          [22] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-mailbox-2.0
              )
      
          [23] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-host-2.0
              )
      
          [24] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-null-2.0
              )
      
          [25] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-package-2.0
              )
      
          [26] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-security-2.0
              )
      
          [27] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-server-2.0
              )
      
          [28] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-support-2.0
              )
      
          [29] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-wbp-2.0
              )
      
          [30] => Array
              (
                  [tag] => extURI
                  [type] => complete
                  [level] => 5
                  [value] => http://www.heartinternet.co.uk/whapi/ext-whapi-2.0
              )
      
          [31] => Array
              (
                  [tag] => svcExtension
                  [type] => close
                  [level] => 4
              )
      
          [32] => Array
              (
                  [tag] => svcMenu
                  [type] => close
                  [level] => 3
              )
      
          [33] => Array
              (
                  [tag] => dcp
                  [type] => open
                  [level] => 3
              )
      
          [34] => Array
              (
                  [tag] => access
                  [type] => open
                  [level] => 4
              )
      
          [35] => Array
              (
                  [tag] => all
                  [type] => complete
                  [level] => 5
              )
      
          [36] => Array
              (
                  [tag] => access
                  [type] => close
                  [level] => 4
              )
      
          [37] => Array
              (
                  [tag] => statement
                  [type] => open
                  [level] => 4
              )
      
          [38] => Array
              (
                  [tag] => purpose
                  [type] => open
                  [level] => 5
              )
      
          [39] => Array
              (
                  [tag] => admin
                  [type] => complete
                  [level] => 6
              )
      
          [40] => Array
              (
                  [tag] => prov
                  [type] => complete
                  [level] => 6
              )
      
          [41] => Array
              (
                  [tag] => purpose
                  [type] => close
                  [level] => 5
              )
      
          [42] => Array
              (
                  [tag] => recipient
                  [type] => open
                  [level] => 5
              )
      
          [43] => Array
              (
                  [tag] => ours
                  [type] => complete
                  [level] => 6
              )
      
          [44] => Array
              (
                  [tag] => recipient
                  [type] => close
                  [level] => 5
              )
      
          [45] => Array
              (
                  [tag] => retention
                  [type] => open
                  [level] => 5
              )
      
          [46] => Array
              (
                  [tag] => indefinite
                  [type] => complete
                  [level] => 6
              )
      
          [47] => Array
              (
                  [tag] => retention
                  [type] => close
                  [level] => 5
              )
      
          [48] => Array
              (
                  [tag] => statement
                  [type] => close
                  [level] => 4
              )
      
          [49] => Array
              (
                  [tag] => dcp
                  [type] => close
                  [level] => 3
              )
      
          [50] => Array
              (
                  [tag] => greeting
                  [type] => close
                  [level] => 2
              )
      
          [51] => Array
              (
                  [tag] => epp
                  [type] => close
                  [level] => 1
              )
      
      )
    Thankyou if anyone can work it out im lost haha.

  • #2
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    What's complaining about incorrect configurations? The internal methods, or the result from the server? There are a lot of errors in that first script from non-existing variables to syntactical failures. The second looks like it's job is to generate the output but if it isn't including the first script after it than that is also useless. The third appears to be a resultant, but we haven't a clue how you get there or what it means. For that you need to consult the technical docs from the provider.
    If you are getting a result in the third, that indicates a lot has been removed from the first before posting it here.

  • #3
    New Coder
    Join Date
    Apr 2008
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts
    http://api.heartinternet.co.uk/api2.html is where im referring from :/ it didnt look right to me either.. all i was trying to do was "Connect" then "Initial Command".

  • #4
    New Coder
    Join Date
    Apr 2008
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts
    Does anyone have an idea? haha

  • #5
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,979
    Thanks
    4
    Thanked 2,659 Times in 2,628 Posts
    I'm not going to read through an entire API.
    What is complaining? The internal functions or the results of the server? If its the results of the server, then it sounds like there is no issue with whatever code you are using (not this code since its syntactically incorrect so will never run without throwing an error). That will require you to consult with the remote website and their documentation to determine what you need to do in order to communicate properly between the server and client.

    If its an internal configuration error then we can help with that. But you need to specify what it is.

  • #6
    New Coder
    Join Date
    Apr 2008
    Posts
    36
    Thanks
    4
    Thanked 0 Times in 0 Posts
    I dont really know what it is... well.. thanks for the help anyway...

  • #7
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi...

    I know this is a little late in replying but I wondered if you managed to work out the issues?

    I'm currently trying to connect to the Heart API and I'm getting NO where... !!

    Heart wont offer support either... which is annoying as it's THEIR API and THEIR example coding which I'm using!!

  • #8
    New to the CF scene
    Join Date
    Feb 2013
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Regarding scripting error

    The code that you have provided is correct, the error is may be because of internal system error.


  •  

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •