Browse Source

follow redirects when fetching HTTP requests

pull/3/head
Aaron Parecki 9 years ago
parent
commit
c673a44044
4 changed files with 6 additions and 1 deletions
  1. +3
    -0
      lib/Telegraph/HTTP.php
  2. +2
    -0
      lib/Telegraph/ProfileFetcher.php
  3. BIN
      public/assets/dashboard-screenshot.jpg
  4. +1
    -1
      scripts/telegraph.php

+ 3
- 0
lib/Telegraph/HTTP.php View File

@ -7,6 +7,7 @@ class HTTP {
$ch = curl_init($url); $ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
$response = curl_exec($ch); $response = curl_exec($ch);
$header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE); $header_size = curl_getinfo($ch, CURLINFO_HEADER_SIZE);
return array( return array(
@ -22,6 +23,7 @@ class HTTP {
curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $body); curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_HEADER, true);
if (self::$_proxy) curl_setopt($ch, CURLOPT_PROXY, self::$_proxy); if (self::$_proxy) curl_setopt($ch, CURLOPT_PROXY, self::$_proxy);
$response = curl_exec($ch); $response = curl_exec($ch);
@ -39,6 +41,7 @@ class HTTP {
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_HEADER, true);
curl_setopt($ch, CURLOPT_NOBODY, true); curl_setopt($ch, CURLOPT_NOBODY, true);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);
if (self::$_proxy) curl_setopt($ch, CURLOPT_PROXY, self::$_proxy); if (self::$_proxy) curl_setopt($ch, CURLOPT_PROXY, self::$_proxy);
$response = curl_exec($ch); $response = curl_exec($ch);
return array( return array(

+ 2
- 0
lib/Telegraph/ProfileFetcher.php View File

@ -21,6 +21,8 @@ class ProfileFetcher {
$user->photo = $representative['properties']['photo'][0]; $user->photo = $representative['properties']['photo'][0];
} }
$user->save(); $user->save();
} else {
echo "Couldn't find one\n";
} }
} }

BIN
public/assets/dashboard-screenshot.jpg View File

Before After
Width: 800  |  Height: 638  |  Size: 60 KiB

+ 1
- 1
scripts/telegraph.php View File

@ -2,4 +2,4 @@
chdir('..'); chdir('..');
include('vendor/autoload.php'); include('vendor/autoload.php');
q()->run_workers(2);
q()->run_workers(4);

Loading…
Cancel
Save