Created
September 4, 2015 09:07
-
-
Save tobiastom/903bdb7d04c83b85cef6 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
namespace TobiasTom; | |
use Facebook\HttpClients\FacebookCurl; | |
class FacebookCurlHttpClient extends \Facebook\HttpClients\FacebookCurlHttpClient { | |
protected $pemFile; | |
public function __construct( FacebookCurl $facebookCurl = null, $pemFile = null ) { | |
parent::__construct( $facebookCurl ); | |
if ( $pemFile ) { | |
$this->pemFile = tempnam( sys_get_temp_dir(), 'facebook_' ); | |
copy( $pemFile, $this->pemFile ); | |
} | |
} | |
public function __destruct() { | |
if ( $this->pemFile ) { | |
unlink( $this->pemFile ); | |
} | |
} | |
public function openConnection($url, $method, $body, array $headers, $timeOut) { | |
$result = parent::openConnection( $url, $method, $body, $headers, $timeOut ); | |
if ( $this->pemFile ) { | |
$this->facebookCurl->setopt( CURLOPT_CAINFO, $this->pemFile ); | |
} | |
return $result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment