Getting fsocketopen() Error in cPanel API

Discussion in 'PHP' started by rfresh, Nov 28, 2008.

  1. #1
    I'm trying to use cPanel API to grab my disk space usage and I'm getting the following error - I'm using cPanel API.

    Warning: fsockopen() [function.fsockopen]: unable to connect to mywebsite.com:2082 (Connection timed out) in /home/mywebsite/public_html/cPanel.php on line 53
    Disk Space Used: 0 MB

    This is my small test code (my real login parameters removed):

    
    include "cPanel.php"; 
    $cPanel = new cPanel('mywebsite.com', 'username', 'password', 2082, false); 
    echo 'Disk Space Used: ' . $cPanel->getSpaceUsed() . ' MB<br>'; 
    
    PHP:
     
    rfresh, Nov 28, 2008 IP
  2. EricBruggema

    EricBruggema Well-Known Member

    Messages:
    1,740
    Likes Received:
    28
    Best Answers:
    13
    Trophy Points:
    175
    #2
    It looks like you CAN'T connect to that url. Maby you don't have permission to access sites outside your own domain!
     
    EricBruggema, Nov 29, 2008 IP
  3. rfresh

    rfresh Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #3
    I own the site I'm connecting to. I'm even running my small test script on that same site so I should be able to access it's cpanel account...but I can't for some reason.
     
    rfresh, Nov 29, 2008 IP
  4. rfresh

    rfresh Peon

    Messages:
    14
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    The problem was my hosting providers firewall. They suggested I use "localhost" instead of the domain name. So I did that and it fixed that fsockopen() error.

    
    include "cPanel.php";  
    $cPanel = new cPanel('localhost', 'username', 'password', 2082, false);  
    echo 'Disk Space Used: ' . $cPanel->getSpaceUsed() . ' MB<br>';  
    
    PHP:
    Now however, the Disk Space Used is 0MB and that isn't right. Username and Userpassword should connect to the target cPanel account and fetch the disk space used. Does anyone have any idea's on this issue?
     
    rfresh, Nov 30, 2008 IP