Plugin Directory

Changeset 1458863


Ignore:
Timestamp:
07/22/2016 10:03:55 AM (10 years ago)
Author:
KrzyKuStudio
Message:

version 1.1

Location:
fb-display-events-shortcode
Files:
23 added
2 edited

Legend:

Unmodified
Added
Removed
  • fb-display-events-shortcode/trunk/fb-display-events-shortcode.php

    r1285473 r1458863  
    145145        )
    146146    );
    147 
     147   
    148148    try
    149149    {
    150         $json = file_get_contents($json_link);
     150        $json = file_get_contents_curl_my($json_link);
    151151    }
    152152    catch (Exception $e)
     
    248248    try
    249249    {
    250         $json = file_get_contents($json_link);
     250        $json = file_get_contents_curl_my($json_link);
    251251    }
    252252    catch (Exception $e)
     
    426426    return $translated;
    427427}
    428 
     428function file_get_contents_curl_my($url, $retries=5) {
     429{
     430    $ua = 'Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.1)';
     431    if (extension_loaded('curl') === true)
     432    {
     433        $ch = curl_init();
     434        curl_setopt($ch, CURLOPT_URL, $url); // The URL to fetch. This can also be set when initializing a session with curl_init().
     435        curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE); // TRUE to return the transfer as a string of the return value of curl_exec() instead of outputting it out directly.
     436        curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
     437        curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, 5); // The number of seconds to wait while trying to connect.
     438        curl_setopt($ch, CURLOPT_USERAGENT, $ua); // The contents of the "User-Agent: " header to be used in a HTTP request.
     439        curl_setopt($ch, CURLOPT_FAILONERROR, TRUE); // To fail silently if the HTTP code returned is greater than or equal to 400.
     440        curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); // To follow any "Location: " header that the server sends as part of the HTTP header.
     441        curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE); // To automatically set the Referer: field in requests where it follows a Location: redirect.
     442        curl_setopt($ch, CURLOPT_TIMEOUT, 5); // The maximum number of seconds to allow cURL functions to execute.
     443        curl_setopt($ch, CURLOPT_MAXREDIRS, 5); // The maximum number of redirects
     444        $result = trim(curl_exec($ch));
     445       
     446        curl_close($ch);
     447    }
     448    else
     449    {
     450        $result = trim(file_get_contents($url));
     451    }       
     452    if (empty($result) === true)
     453    {
     454        $result = false;
     455        if ($retries >= 1)
     456        {
     457            sleep(1);
     458            return file_get_contents_curl_my($url, --$retries);
     459        }
     460    }   
     461    return $result;
     462}
     463}
    429464/**
    430465* Display message that fb_user_id or fb_event_id is not setted
  • fb-display-events-shortcode/trunk/readme.txt

    r1285473 r1458863  
    55Tags: Facebook, shortcode, event, events, fb, list
    66Requires at least: 3.1
    7 Tested up to: 4.3.1
    8 Stable tag: 1.0
     7Tested up to: 4.5.3
     8Stable tag: 1.1
    99License: GPLv2
    1010License URI: http://www.gnu.org/licenses/gpl-2.0.html
     
    8787example curl.cainfo = "c:\xampp\cacert.pem"
    8888
     89= How to check if token is working =
     90
     91Sample below is generated from plugin. Just replace XXXXX with your token. Place that link into browser. If the token is valid you will get data from facebook. You can modify this url. 463776883765579 is user id. Sice and until are timestamps.
     92
     93https://graph.facebook.com/463776883765579/events/attending/?fields=id,name,description,place,timezone,start_time,cover&access_token=XXXXXXXXXXXXXXXXXXX&since=1388534400&until=1468972800
     94
     95
    8996== Screenshots ==
    9097
     
    95102== Changelog ==
    96103
     104= 1.1 =
     105Upgraded data access to fb not only via file_get_contents but also cURL
     106
    97107= 1.0 =
    98108* Initial release
     
    100110== Upgrade Notice ==
    101111
     112= 1.1 =
     113Upgraded data access to fb not only via file_get_contents but also cURL
     114
    102115= 1.0 =
    103116Initial release
Note: See TracChangeset for help on using the changeset viewer.