Skip to content

Instantly share code, notes, and snippets.

@r15ch13
Last active October 12, 2015 17:08
Show Gist options
  • Save r15ch13/4059596 to your computer and use it in GitHub Desktop.
Save r15ch13/4059596 to your computer and use it in GitHub Desktop.
Saferpay cURL Issue
<?php
error_reporting(E_ALL);
ini_set("display_errors", "on");
$url = "https://www.saferpay.com/user/FileImport/ScriptUpload.aspx";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_HEADER, false);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
// Windows (PHP 5.3.1)
$file = 'D:\\xampp\\htdocs\\saferpay\\99867-GL01.IN';
$file = sprintf('@%s', realpath($file));
// Linux (PHP 5.4.9)
$file = '/Users/Test/Sites/saferpay/99867-GL01.IN';
$file = sprintf('@%s;filename=%s', realpath($file), basename($file));
$post = array(
"CustomerID" => "99867",
"spUsername" => "e99867001",
"spPassword" => "XAjc3Kna",
"UAFState" => "login",
"file" => $file,
);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
$result = curl_exec($ch);
echo "<pre>";
echo curl_errno($ch).": ".curl_error($ch);
echo PHP_EOL;
echo htmlentities($result);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment