Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
cURL Proxy Connection for a Shop Script
Old 09-01-2008, 12:07 AM cURL Proxy Connection for a Shop Script
ajreaper's Avatar
Junior Talker

Posts: 1
Name: Jenna
Location: San Diego
Trades: 0
For about four hours I was racking my brain on this stupid problem and for whatever reason I cannot fix it. I have been repeating the SAME THING over and over again with the same results.

I have Shop Script PRO. The Author won't help me because I purchased the script from a second party (might have been a reseller but I don't know, but I did pay for it). I did ask the Author for a module or instructions on how to modify the usps shipping module on my own, but they wanted an ORDER ID, which I don't have. So... I am trying to figure it out on my own. They did tell me, however, that the script doesn't need a complete rewrite but modifications have to be done to the cURL coding. So far I have come to the point where I hate GoDaddy to the point where I want to vomit blood.

Yes, the host we have is GODADDY (shared, linux). The server has cURL installed but it requires a proxy server. I modified the cURL code, but I am still unable to get real-time USPS shipping quotes.

Here is the color syntax of the entire module: http://cosmicgivers.com/codesyntax.html


My Errors:

cURL - Initially I was getting error 7, then error 28 and error 56. The errors stopped showing after I made an alteration to the API url, as suggested by a few sites.

USPS - The errors I receive are either 1001 (which may be just access points?), API Authorization failure. RateV2 is not a valid API name for this protocol. (with http://production.shippingapis.com) and Authorization failure. You are not authorized to connect to this server. (with https://secure.shippingapis.com ). I have an email stating that our account is live so that isn't an issue.


I also considered just installing it in my root on the GoDaddy account (since I cannot access any subfolders). I am not sure if that would work and, further more, I have absolutely no idea how I would do that. The site using this script is: https://cosmicgivers.com/shop/ What is SUPPOSED to appear is, on the first step of checkout, there SHOULD be a drop down box with the shipping quotes. Unfortunately it hasn't yet done that.


Code:
    function _sendXMLQuery($_XMLQuery){

    if(!$_XMLQuery)return '';
    if ( !($ch = curl_init()) ){
    
    $this->_writeLogMessage(MODULE_LOG_CURL, 'Local error: '.ERR_CURLINIT)
    return ERR_CURLINIT;
    }

    if ( curl_errno($ch) != 0 ){
    
    $this->_writeLogMessage(MODULE_LOG_CURL, 'Curl error: '.curl_errno($ch))
    return ERR_CURLINIT;
    }

    if(strpos($_XMLQuery, 'RateV2Request')===false)
    $_Type = 'International';
    else 
    $_Type = 'Domestic';
    
    switch ($_Type){
    case 'Domestic':
    $url = 'http://production.shippingapis.com/shippingapi.dll?API=RateV2&XML='.urlencode($_XMLQuery)
    break;
    case 'International':
    $url = 'https://secure.shippingapis.com/shippingapi.dll?API=IntlRate&XML='.urlencode($_XMLQuery)
    break;
    }

    @curl_setopt( $ch, CURLOPT_URL, $url )
    @curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 )
    @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0 )
    @curl_setopt($ch, CURLOPT_TIMEOUT, 120 )
    @curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP)
        @curl_setopt($ch, CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128")

    $result = @curl_exec($ch)
    if ( curl_errno($ch) != 0){
    
    $this->_writeLogMessage(MODULE_LOG_CURL, 'Curl error: '.curl_errno($ch))
    return ERR_CURLEXEC;
    }

    curl_close($ch)
    
    return $result;
    }
[hr]


Oh, and also... what I tried:

cURL:

I added

Code:
@curl_setopt($ch, CURLOPT_PROXYTYPE, CURLPROXY_HTTP)
@curl_setopt($ch, CURLOPT_PROXY,"http://proxy.shr.secureserver.net:3128")
to

Code:
@curl_setopt( $ch, CURLOPT_URL, $url )
@curl_setopt( $ch, CURLOPT_RETURNTRANSFER, 1 )
@curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0 )
@curl_setopt( $ch, CURLOPT_TIMEOUT, 10 )
And then changed the timeout to 120 to get rid of one of the cURL errors.

After that change I was getting errors in my usps log. So I changed:

Code:
switch ($_Type){
case 'Domestic':
$url = 'https://secure.shippingapis.com/shippingapi.dll?API=RateV2&XML='.urlencode($_XMLQuery)
break;
case 'International':
$url = 'https://secure.shippingapis.com/shippingapi.dll?API=IntlRate&XML='.urlencode($_XMLQuery)
break;
}
to

Code:
switch ($_Type){
case 'Domestic':
$url = 'http://production.shippingapis.com/shippingapi.dll?API=RateV2&XML='.urlencode($_XMLQuery)
break;
case 'International':
$url = 'https://secure.shippingapis.com/shippingapi.dll?API=IntlRate&XML='.urlencode($_XMLQuery)
break;
}
My last cURL error was at 3 in the morning and it was Curl error: 28. It hasn't shown any new errors since modifying the urls as seen above.

With the above changes I receive USPS error:
Authorization failure. You are not authorized to connect to this server.

With BOTH urls changed to http://production.shippingapis.com/shippingapi.dll I receive this error:
[DATE] [TIMECODE]
1001


After the changes are made to cURL, the default settings for the url result in:
API Authorization failure. RateV2 is not a valid API name for this protocol.

But before that it is:
[DATE] [TIMECODE]
1001



I have also:
-Removed the @s in front of the curl tags
-Changed the proxy server to http://64.202.165.130:3128
-Switched around 1 and 0 for FALSE and TRUE (not not NULL)
-Used port 443 instead
-Changed anything saying HTTP to HTTPS (with the above)
-Screamed, yelled, and swore in hopes I might scare the script into working...


I can also upload the error logs if needed.
ajreaper is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Reply     « Reply to cURL Proxy Connection for a Shop Script
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.30182 seconds with 12 queries