Skip to content

Instantly share code, notes, and snippets.

@tobiastom
Created September 4, 2015 09:07
Show Gist options
  • Save tobiastom/903bdb7d04c83b85cef6 to your computer and use it in GitHub Desktop.
Save tobiastom/903bdb7d04c83b85cef6 to your computer and use it in GitHub Desktop.
<?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