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 7 of 7

Thread: Socket help

  1. #1
    New Coder
    Join Date
    Oct 2010
    Posts
    29
    Thanks
    0
    Thanked 2 Times in 2 Posts

    Socket help

    I've been trying and trying to get this right. Please, any help would be fantastic.

    I am trying to upload a feed file to ebay using the following PHP code:
    PHP Code:
    <?php

    $key 
    "MY_TOKEN_GOES_HERE";

    set_time_limit(0);

    // GET THE FEED FILE -- this part works
    $options = array(
        
    CURLOPT_RETURNTRANSFER => true,     // return web page
        
    CURLOPT_HEADER         => false,    // don't return headers
        
    CURLOPT_FOLLOWLOCATION => true,     // follow redirects
        
    CURLOPT_ENCODING       => "",       // handle all encodings
        
    CURLOPT_USERAGENT      => "me"// who am i
        
    CURLOPT_AUTOREFERER    => true,     // set referer on redirect
        
    CURLOPT_CONNECTTIMEOUT => 120,      // timeout on connect
        
    CURLOPT_TIMEOUT        => 120,      // timeout on response
        
    CURLOPT_MAXREDIRS      => 10,       // stop after 10 redirects
        
    CURLOPT_SSL_VERIFYPEER => false,
    );

    $ch curl_init('https://www.mysite/pull_feed.php');
    curl_setopt_array$ch$options );
    $contents curl_exec$ch );
    curl_close$ch );

    //----------------------------------------------------//
    //      . . . Somewhere in here is the problem. . . .         //
    //----------------------------------------------------//

    // CREATE THE REQUEST
    $request "POST /ws/eBayISAPI.dll?FileExchangeUpload HTTP/1.1\r\n";
    $request .= "Connection: Keep-Alive\r\n";
    $request .= "User-Agent: My Client App v1.0\r\n";
    $request .= "Host: bulksell.ebay.com\r\n";
    //$request .= "https://bulksell.ebay.com/ws/eBayISAPI.dll?FileExchangeUpload\r\n";
    $request .= "Content-Length: ".strlen($contents.$key."token file     ")."\r\n";
    $request .= "Content-type: multipart/form-data; ";
    $request .= "boundary=THIS_STRING_SEPARATES\r\n\r\n";
    $request .= "--THIS_STRING_SEPARATES\r\n";
    $request .= "Content-Disposition: form-data; name=\"token\" \r\n\r\n";
    $request .= $key."\r\n";
    $request .= "--THIS_STRING_SEPARATES\r\n";
    $request .= "Content-Disposition: form-data; name=\"file\"; ";
    $request .= "filename=\"listings.csv\"\r\n";
    $request .= "Content-Type: text/csv\r\n\r\n";
    $request .= $contents."\r\n";
    $request .= "--THIS_STRING_SEPARATES\r\n";

    //OPEN THE CONNECTION
    $conn fsockopen('ssl://bulksell.ebay.com'443);

    // SEND THE REQUEST
    fputs($conn$request);

    // GET THE RESULT
    while(!feof($conn)) {
        echo 
    fgets($conn128);
    }

    // CLOSE CONNECTION
    fclose($conn);

    ?>
    The $request looks like this:
    Code:
    POST /ws/eBayISAPI.dll?FileExchangeUpload HTTP/1.1
    Connection: Keep-Alive
    User-Agent: My Client App v1.0
    Host: bulksell.ebay.com
    Content-Length: 2601
    Content-type: multipart/form-data; boundary=THIS_STRING_SEPARATES
    
    --THIS_STRING_SEPARATES
    Content-Disposition: form-data; name="token" 
    
    MY_TOKEN_GOES_HERE
    --THIS_STRING_SEPARATES
    Content-Disposition: form-data; name="file"; filename="listings.csv"
    Content-Type: text/csv
    
    *Action(SiteID=US|Country=US|Currency=USD|Version=403|CC=UTF-8),"*Category","*Title","Subtitle","*Description","*ConditionID","PicURL","*Quantity","*Format","*StartPrice","BuyItNowPrice","*Duration"
    . . . . MORE OF THE FILE . . . . 
    
    --THIS_STRING_SEPARATES
    The result that I get from ebay is this:
    HTTP/1.1 200 OK Server: Apache-Coyote/1.1 Set-Cookie: dp1=bu1p/QEBfX0BAX19AQA**4ede560b^; Domain=.ebay.com; Expires=Wed, 05-Dec-2012 17:51:07 GMT; Path=/ Set-Cookie: s=CgAD4ACBM/nQLYmNjZWYxYmIxMmMwYTIzMzU1NDA3N2EwZmZmZmZjZWJZfmC0; Domain=.ebay.com; Path=/ Set-Cookie: nonsession=CgADKACBWYyQLYmNjZWYxYmIxMmMwYTIzMzU1NDA3N2EwZmZmZmZjZWIAywABTP0pkzGfas7R; Domain=.ebay.com; Expires=Tue, 06-Dec-2011 17:51:07 GMT; Path=/ Cache-Control: private Pragma: no-cache Content-Type: text/html;charset=UTF-8 Content-Length: 755 Date: Mon, 06 Dec 2010 17:51:07 GMT An unknown problem interrupted the file transfer. Please try again.
    CloseHTTP/1.1 400 Bad Request Content-Length:54 Connection: close Http/1.1 Bad Request
    Any help would be great. I'm really struggling with this one.

    Thanks,
    jmace

  • #2
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    Have you been using the ebay sandbox to test this stuff? Do you get the same results there?

    Also what part of the ebay documentation have you been following for this? I tried to find it myself but there's a boatload of different APIs and I'm not sure which one you're using.

  • #3
    New Coder
    Join Date
    Oct 2010
    Posts
    29
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Thanks for the response.

    I haven't tried the sandbox. I'm actually not sure where it's located or how to use the it.

    As for documentation, all I have is this:
    http://pics.ebaystatic.com/aw/pics/p...structions.pdf
    Starting on page 34

  • #4
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    You're putting an actual token in place of the string "MY_TOKEN_GOES_HERE", right?

  • #5
    New Coder
    Join Date
    Oct 2010
    Posts
    29
    Thanks
    0
    Thanked 2 Times in 2 Posts
    Yes, the actual token is there, but I obviously can't show that. If I change the token I get an invalid token message, so I know the token is correct.

  • #6
    UE Antagonizer Fumigator's Avatar
    Join Date
    Dec 2005
    Location
    Utah, USA, Northwestern hemisphere, Earth, Solar System, Milky Way Galaxy, Alpha Quadrant
    Posts
    7,691
    Thanks
    42
    Thanked 637 Times in 625 Posts
    OK just making sure...

    From here I can't really tell what might be wrong. I suggest going to the sandbox and working it out there. I've done similar POST requests for Paypal and they can be tricky to troubleshoot. Paypal's sandbox has some additional debugging tools that gave me a better picture of what was going on so I was able to find the problem fairly easily. Since Paypal and ebay are the same company, I'd imagine ebay's sandbox has similar debugging tools, which should help you track the problem down.

  • #7
    New to the CF scene
    Join Date
    Jan 2011
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I found a code snippet online that can upload a csv and send it through the ebay content API. Not sure it this helps.

    https://checkout.google.com/view/buy...27401048812945
    Last edited by coremega2002; 01-28-2011 at 02:44 AM.


  •  

    Posting Permissions

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