0

Why am I getting Notice: Undefined offset: 1 on this line $lt = $match[1];

$cookiePath = dirname(__FILE__).'/cookies/file.txt';

$url = 'https://signin.infusionsoft.com/login';

$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_COOKIEJAR, $cookiePath);
curl_setopt($ch, CURLOPT_COOKIEFILE, $cookiePath);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);//$followLocation
curl_setopt($ch, CURLOPT_POST, false);
$response = curl_exec($ch);
    curl_close($ch);

preg_match('/<input[^<>]+name="lt"[^<>]+value="([^<>"]+)"/i', $response, $match);
$lt = $match[1];

preg_match('/<input[^<>]+name="execution"[^<>]+value="([^<>"]+)"/i', $response, $match);
$execution = $match[1];

preg_match('/<input[^<>]+name="_eventId"[^<>]+value="([^<>"]+)"/i', $response, $match);
$_eventId = $match[1];

preg_match('/<input[^<>]+name="app_version"[^<>]+value="([^<>"]+)"/i', $response, $match);
$app_version = $match[1];


$post = array(
    'lt'            => $lt,
    'execution'     => $execution,
    '_eventId'      => $_eventId,
    'app_version'   => $app_version,
    'username'      => $infusionsoftEmail,
    'password'      => $infusionsoftPassword,
    '_csrf'         => 'null'
);
Jess McKenzie
  • 8,345
  • 27
  • 100
  • 170
  • because `$match[1]` is not set –  Apr 09 '18 at 03:52
  • Possible duplicate of [PHP: "Notice: Undefined variable", "Notice: Undefined index", and "Notice: Undefined offset"](https://stackoverflow.com/questions/4261133/php-notice-undefined-variable-notice-undefined-index-and-notice-undef) –  Apr 09 '18 at 03:54

0 Answers0