Skip to content
This repository has been archived by the owner on Dec 4, 2018. It is now read-only.

Changes to handle foursquare invalid cert #14

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions EpiFoursquare.php
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,13 @@ class EpiFoursquare
protected $connectionTimeout = 5;
protected $requestTimeout = 30;
protected $debug = false;
protected $verifyCert = false;

public function getAccessToken($code, $redirectUri)
{
$params = array('client_id' => $this->clientId, 'client_secret' => $this->clientSecret, 'grant_type' => 'authorization_code', 'redirect_uri' => $redirectUri, 'code' => $code);
$qs = http_build_query($params);
return $this->request('GET', "{$this->accessTokenUrl}?{$qs}");
return $this->request('GET', "{$this->accessTokenUrl}", $params);
}

public function getAuthorizeUrl($redirectUri)
Expand Down Expand Up @@ -112,14 +113,12 @@ private function request($method, $endpoint, $params = null)
if($method === 'GET')
$url .= is_null($params) ? '' : '?'.http_build_query($params, '', '&');
$ch = curl_init($url);
//print_r($url);exit;
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:'));
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, $this->verifyCert);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, $this->requestTimeout);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, $method);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
if(isset($_SERVER ['SERVER_ADDR']) && !empty($_SERVER['SERVER_ADDR']) && $_SERVER['SERVER_ADDR'] != '127.0.0.1')
curl_setopt($ch, CURLOPT_INTERFACE, $_SERVER ['SERVER_ADDR']);
if($method === 'POST' && $params !== null)
{
curl_setopt($ch, CURLOPT_POSTFIELDS, http_build_query($params));
Expand Down