解析错误:语法错误,意外的T_DOUBLE_ARROW in ... with IPN

时间:2015-01-24 15:37:15

标签: php paypal-ipn

我收到以下错误:

  

解析错误:语法错误,第24行/homepages/6/d354573317/htdocs/Test/ipn/ipn-handler.php中的意外T_DOUBLE_ARROW

我尝试使用paypal连接到IPN,最终获取我的交易数据。如果有人能指出我的代码中的错误在哪里,我会非常感激。

代码是:

<?php 

class Paypal_IPN
{
    /** @var string $_url The paypal url to go to through cURL
    private $_url;

    /**
    * @param string $mode 'live' or 'sandbox' 
    */
    public function __construct($mode = 'live')
    {
        if ($mode == 'live')
        $this->_url = 'https://www.paypal.com/cgi-bin/webscr';

        else
        $this->_url = 'https://www.sandbox.paypal.com/cgi-bin/webscr';
    }

    public function run()
    {
        $postFields = 'cmd=_notify-validate';

        foreach($_POST as $key => $value)
        {
            $postFields .= "&$key=".urlencode($value);
        }

        $ch = curl_init();

        curl_setopt_array($ch, array(
            CURLOPT_URL => $this->_url,
            CURLOPT_RETURNTRANSFER => true,
            CURLOPT_SSL_VERIFYPEER => false,
            CURLOPT_POST => true,
            CURLOPT_POSTFIELDS => $postFields
        ));

        $result = curl_exec($ch);
        curl_close($ch);

        $fh = fopen('result.txt', 'w');
        fwrite($fh, $result . ' -- ' . $postFields);
        fclose($fh);

        echo $result;
    }
}

?>

0 个答案:

没有答案