Skip to content

Commit

Permalink
Bing API bug fix
Browse files Browse the repository at this point in the history
CURL request to Bing API was failing in some hosting environments.  Bug
fixed.
  • Loading branch information
PromInc committed Sep 15, 2015
1 parent a4aef8b commit 5a91a72
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
16 changes: 10 additions & 6 deletions organic-search-analytics/apis/Bing/Webmasters.php
Original file line number Diff line number Diff line change
Expand Up @@ -32,18 +32,22 @@ class BingWebmasters
*/
public function requestApi( $api_key, $method, $siteUrl = NULL ) {
$url = self::URL_BING_WEBMASTERS_JSON.$method.'?apikey='.$api_key;

if( $siteUrl ) {
$url .= '&siteUrl='.$siteUrl;
}

$ch = curl_init();
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

$result = curl_exec($ch);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);

if( ! $result = curl_exec($ch) ) {
$alert = array("type"=>"error", "message"=>"Error communicating with the Bing API");
}

curl_close($ch);

return $result;
}

Expand Down
4 changes: 2 additions & 2 deletions organic-search-analytics/inc/code/dataCapture.php
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,9 @@ public function getSitesGoogleSearchConsole() {
*
* @returns Array
*/
public function getSitesBingWebmaster($enabledCheck = FALSE) {
public function getSitesBingWebmaster($enabledCheck = FALSE) {
$bing = new BingWebmasters(); // Load Bing Webmasters API

$bingSites = json_decode( $bing->requestApi( config::CREDENTIALS_BING_API_KEY, 'GetUserSites' ) );

$return = array();
Expand Down

0 comments on commit 5a91a72

Please sign in to comment.