SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Enthusiast edgarzakaryan's Avatar
    Join Date
    Aug 2012
    Location
    Yerevan, Armenia
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    put port in curl

    Hi everyone.
    I want to send xml data using curl, and I need to put in my script port 8080.

    Here is my script, but it doesn't work, I'm thinking maybe server don't allow me to send post to this port?

    Code:
    $post_url = "http://SOMEIP:8080/";
    $xml_string = '<?xml version="1.0" encoding="UTF-8"?>';
    
    
    $ch = curl_init($post_url);
    
    curl_setopt ($ch, CURLOPT_POST, true);
    curl_setopt ($ch, CURLOPT_PORT , 8080);
    curl_setopt ($ch, CURLOPT_POSTFIELDS, "xmldata=".$xml_string);
    
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    curl_setopt($ch, CURLOPT_VERBOSE, 1);
    
    
    $data = curl_exec($ch); 
    // to get information on the curl resultset
    $info = curl_getinfo($ch);
    print_r($data);
    if(curl_errno($ch)){
        print curl_error($ch);
    }
    
    curl_close($ch);

  2. #2
    SitePoint Member
    Join Date
    Aug 2012
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You might want to check with your hosting provider, they may be blocking the port on outbound at the firewall.

  3. #3
    SitePoint Zealot
    Join Date
    Jul 2012
    Location
    Scarborough, North Yorkshire, United Kingdom
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Do you get any error messages?

  4. #4
    SitePoint Enthusiast edgarzakaryan's Avatar
    Join Date
    Aug 2012
    Location
    Yerevan, Armenia
    Posts
    44
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by RichardAskew View Post
    Do you get any error messages?
    Yes, when I'm using port, it's telling me that it couldn't connect to the host. But when I'm removing the port, it's successfully sends datas.

  5. #5
    SitePoint Zealot
    Join Date
    Jul 2012
    Location
    Scarborough, North Yorkshire, United Kingdom
    Posts
    100
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    edgarzakaryan

    This, drop them a support ticket, code looks fine to me

    Quote Originally Posted by ironcladservers View Post
    You might want to check with your hosting provider, they may be blocking the port on outbound at the firewall.


Tags for this Thread

Bookmarks

Posting Permissions

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