PHP/CURL script not working anymore. Please Help

Discussion in 'PHP' started by carbasan, Jun 16, 2012.

  1. #1
    Hi

    I have this php/curl script that logs into eBay. The script worked great until few weeks ago when eBay changed something in their authentication method. Could someone help me to fix this script? I don't know much about curl so I don't know what to do. Thanks

    <?php
    $userid = "test_username";
    $pass = "password";


    $login_url = "https://signin.ebay.com/ws/eBayISAPI.dll?SignIn&ru=http%3A%2F%2Fwww.ebay.com%2F";
    curl_cookie_set($login_url);


    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.4) Gecko/20111001 Firefox/3.20.0" );
    curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt( $ch, CURLOPT_MAXREDIRS, 5);
    $referer = $login_url;
    $submit_url = "https://signin.ebay.com/ws/eBayISAPI.dll?co_partnerId=2&siteid=0&UsingSSL=1";
    $postfields = 'MfcISAPICommand=SignInWelcome&bhid=a1%3D5~a2%3D7~a3%3D22145~a4%3DMozilla~a5%3DMicrosoft%20Internet%20Explorer~a6%3D4.0%20(compatible%3B%20MSIE%206.0%3B%20Windows%20NT%205.1%3B%20SV1%3B%20FunWebProducts%3B%20.NET%20CLR%202.0.50727%3B%20.NET%20CLR%203.0.4506.2152%3B%20.NET%20CLR%203.5.30729)~a7%3D%3BSP3%3B~a8%3Den-us~a9%3Dtrue~a10%3Dx86~a11%3Dtrue~a12%3DWin32~a13%3Den-us~a14%3DMozilla%2F4.0%20(compatible%3B%20MSIE%206.0%3B%20Windows%20NT%205.1%3B%20SV1%3B%20FunWebProducts%3B%20.NET%20CLR%202.0.50727%3B%20.NET%20CLR%203.0.4506.2152%3B%20.NET%20CLR%203.5.30729)~a15%3Dtrue~a16%3Den-us~a17%3Dwindows-1252~a18%3Dsignin.ebay.com~a19%3D96~a20%3D96~a21%3Dtrue~a22%3D0~a23%3D1024~a24%3D768~a25%3D32~a26%3D738~a27%3D1024~a28%3DThu%20Mar%2011%2011%3A16%3A37%20CST%202010~a29%3D-6~a30%3Dabk%3D6%2C0%2C2900%2C5512%7Cwnt%3D6%2C0%2C2900%2C5512%7Cdht%3D5%2C5000%2C3130%2C0%7Cdhj%3D6%2C0%2C1%2C223%7Cdan%3D6%2C0%2C3%2C531%7Cdsh%3D9%2C0%2C0%2C4503%7Cie5%3D6%2C0%2C2900%2C5512%7Cicw%3D5%2C0%2C2918%2C1900%7Cieh%3D6%2C0%2C2600%2C0%7Ciee%3D4%2C74%2C9273%2C0%7Cwmp%3D9%2C0%2C0%2C4503%7Cobp%3D6%2C0%2C2900%2C5512%7Coex%3D6%2C0%2C2900%2C5512%7Cnet%3D4%2C4%2C0%2C3400%7Ctks%3D4%2C71%2C1968%2C1%7Cmvm%3D5%2C0%2C5000%2C0%7C~a31%3Dyes~a32%3Dx86~a33%3Dyes~a34%3Dno~a35%3Dno~a36%3Dno~a37%3Dno~a38%3Donline~a39%3Dno~a40%3DWin32~a41%3Dno~a42%3Dno~a43%3DT%3D0|o%3D187|r%3D78|p%3D110|i%3D93|g%3D63|-%3D140|F%3D235|U%3D109|C%3D110|K%3D78|Y%3D172|O%3D109|U%3D94|&UsingSSL=1&inputversion=2&lse=true&lsv=11.2.202&mid=AQAAATcAi%2Bn2AAUxMzczMTVlYjRiNS5hNTY3MjVlLmI5ZTAuZmZlNGY3ZWE24BcSww%2BlDyUz32iPaY576SK3Pw**&kgver=1&kgupg=1&kgstate=r&omid=&hmid=&rhr=f&siteid=0&co_partnerId=2&ru=http%3A%2F%2Fwww.ebay.com%2F&pp=&pa1=&pa2=&pa3=&i1=-1&pageType=-1&rtmData=PS%3DT.0&kgct=&userid=' . $userid . '&pass=' . $pass . '&keepMeSignInOption=0&kdata=%1E%1F%10%1E1268327798856%1E1%1FT%1E1268327798981%1E1%1F%10%1E1268327799027%1E0%1FT%1E1268327799121%1E0%1FO%1E1268327799168%1E1%1FO%1E1268327799246%1E0%1FR%1E1268327799246%1E1%1FP%1E1268327799356%1E1%1FR%1E1268327799371%1E0%1FI%1E1268327799449%1E1%1FP%1E1268327799465%1E0%1FG%1E1268327799512%1E1%1FI%1E1268327799527%1E0%1FG%1E1268327799621%1E0%1F%BD%1E1268327799652%1E1%1F%BD%1E1268327799746%1E0%1F%10%1E1268327799809%1E1%1FF%1E1268327799887%1E1%1FU%1E1268327799981%1E1%1FF%1E1268327800012%1E0%1FU%1E1268327800059%1E0%1FC%1E1268327800106%1E1%1FK%1E1268327800184%1E1%1FC%1E1268327800231%1E0%1FK%1E1268327800277%1E0%1FY%1E1268327800356%1E1%1FY%1E1268327800465%1E0%1FO%1E1268327800465%1E1%1FU%1E1268327800559%1E1%1FO%1E1268327800590%1E0%1F%10%1E1268327800637%1E0%1FU%1E1268327800652%1E0%1F%09%1E1268327800762%1E1%1F%09%1E1268327800856%1E0%1F%10%1E1268327801043%1E1%1FF%1E1268327801121%1E1%1FF%1E1268327801231%1E0%1FU%1E1268327801231%1E1%1FU%1E1268327801293%1E0%1FC%1E1268327801356%1E1%1FK%1E1268327801418%1E1%1FC%1E1268327801449%1E0%1FK%1E1268327801527%1E0%1FY%1E1268327801637%1E1%1FY%1E1268327801731%1E0%1FO%1E1268327801731%1E1%1FU%1E1268327801824%1E1%1FO%1E1268327801856%1E0%1FU%1E1268327801918%1E0%1F%10%1E1268327802277%1E0%1F';
    $result = curl_post_request($referer, $submit_url, $postfields, $ch);
    if ( strstr($result, 'Sign out') )
    {
    ... log in successful ...
     
    carbasan, Jun 16, 2012 IP
  2. iMarcus

    iMarcus Active Member

    Messages:
    122
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    90
    #2
    They probably changed the required form fields, and this is preventing your script logging in correctly. Also perhaps there is a timestamp in all that urlencoded text which is causing problems.
    Maybe you should use their api instead?
     
    iMarcus, Jun 17, 2012 IP
  3. webshore88

    webshore88 Well-Known Member

    Messages:
    131
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    123
    #3
    try this
    
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt( $ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; rv:1.7.4) Gecko/20111001 Firefox/3.20.0" );
    curl_setopt( $ch, CURLOPT_FOLLOWLOCATION, true);
    curl_setopt( $ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 2);curl_setopt( $ch, CURLOPT_MAXREDIRS, 5);
    
    PHP:
    hope work for you
     
    webshore88, Jun 18, 2012 IP
  4. Custom IDX/MLS

    Custom IDX/MLS Peon

    Messages:
    23
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #4
    Probably something in the $submit_url variables. I.e. required ones.
     
    Custom IDX/MLS, Jun 19, 2012 IP
  5. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #5
    It is recommended that you search for the mechanism and/or fields they have added or discarded for a certain request that can be performed by CURL, and probably reserialize the the postfields data your have created.

    regards
     
    Vooler, Jun 25, 2012 IP
  6. Vooler

    Vooler Well-Known Member

    Messages:
    1,146
    Likes Received:
    64
    Best Answers:
    4
    Trophy Points:
    150
    #6
    It is recommended that you search for the mechanism and/or fields they have added or discarded for a certain request that can be performed by CURL, and probably reserialize the the postfields data your have created.

    regards
     
    Vooler, Jun 25, 2012 IP