Giter Site home page Giter Site logo

fomo-php-sdk's People

Contributors

baconck avatar davidrojo avatar dincek avatar krzaczek avatar mjaschen avatar tomilsinszki avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

fomo-php-sdk's Issues

Please release 1.0.9

Hi,

Could You please release a 1.0.9 version. There are some nice changes in the repo (error handling and exceptions).

Pawel

No Error Handling for HTTP Requests

Hi!

The FomoClient class does not implement a proper error handling for failed HTTP requests. As a result PHP dies with a fatal error if the UseFomo API isn't responding successfully when trying to cast the response into one of the Fomo objects:

[09-Dec-2016 11:48:00 UTC] PHP Warning:  file_get_contents(https://www.usefomo.com/api/v1/applications/me/events): failed to open stream: HTTP request failed! HTTP/1.1 530 
 in /[**redacted**]/usefomo/fomo-php-sdk/src/Fomo/FomoClient.php on line 182
[09-Dec-2016 11:48:00 UTC] PHP Warning:  ReflectionObject::__construct() expects parameter 1 to be object, null given in /[**redacted**]/usefomo/fomo-php-sdk/src/Fomo/FomoClient.php on line 200
[09-Dec-2016 11:48:00 UTC] PHP Fatal error:  ReflectionClass::getProperties(): Internal error: Failed to retrieve the reflection object in /[**redacted**]/usefomo/fomo-php-sdk/src/Fomo/FomoClient.php on line 202

No error handling in makeRequest method

Hi,

There is no propper error handling in makeRequest method. If the fomo sever returns let's say 500 Internal Server error the $response variable will have HTML error page ... which will result in function returning null and an Warning

ReflectionObject::__construct() expects parameter 1 to be object, null given

A simple fix should check the returned http code to verify it's a successful response. A Fix is on it's way.

Example server error response

<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, user-scalable=no"/>
    <meta name="description" content="Fomo is the world's first social proof marketing platform.">
    <meta property="og:image:width" content="1200" />
    <meta property="og:image:height" content="640" />
    <meta name="twitter:card" content="summary_large_image"/>
    <meta name="twitter:site" content="@usefomo"/>
    <meta property="og:locale" content="en_US"/>
    <meta property="fb:app_id" content="616061058603360">
    <title>Fomo | Internal server error</title>
    <!-- Custom styles for this template -->
    <!-- Built main.css style -->
    <link href="/landing/styles/main-c7384e5ec7.css" rel="stylesheet">
    <!-- End Built css -->
    <link rel="icon" type="image/x-icon" href="/landing/images/logo/favicon.ico">

    <script>
        !function() {
            var t;
            return t = window.driftt = window.drift = window.driftt || [], t.init ? void 0 : t.invoked ? void (window.console && console.error && console.error("Drift snippet included twice.")) : (t.invoked = !0,
                t.methods = [ "identify", "track", "reset", "debug", "show", "ping", "page", "hide", "off", "on" ],
                t.factory = function(e) {
                    return function() {
                        var n;
                        return n = Array.prototype.slice.call(arguments), n.unshift(e), t.push(n), t;
                    };
                }, t.methods.forEach(function(e) {
                t[e] = t.factory(e);
            }), t.load = function(t) {
                var e, n, o, r;
                e = 3e5, r = Math.ceil(new Date() / e) * e, o = document.createElement("script"),
                    o.type = "text/javascript", o.async = !0, o.crossorigin = "anonymous", o.src = "https://js.driftt.com/include/" + r + "/" + t + ".js",
                    n = document.getElementsByTagName("script")[0], n.parentNode.insertBefore(o, n);
            });
        }();
        drift.SNIPPET_VERSION = '0.2.0'
        drift.load('igne9xxxn7cu');
    </script>

    <script>
        (function(h,o,t,j,a,r){
            h.hj=h.hj||function(){(h.hj.q=h.hj.q||[]).push(arguments)};
            h._hjSettings={hjid:369385,hjsv:5};
            a=o.getElementsByTagName('head')[0];
            r=o.createElement('script');r.async=1;
            r.src=t+h._hjSettings.hjid+j+h._hjSettings.hjsv;
            a.appendChild(r);
        })(window,document,'//static.hotjar.com/c/hotjar-','.js?sv=');
    </script>

    <!-- Facebook Pixel Code -->
    <script>
        !function(f,b,e,v,n,t,s){if(f.fbq)return;n=f.fbq=function(){n.callMethod?
            n.callMethod.apply(n,arguments):n.queue.push(arguments)};if(!f._fbq)f._fbq=n;
            n.push=n;n.loaded=!0;n.version='2.0';n.queue=[];t=b.createElement(e);t.async=!0;
            t.src=v;s=b.getElementsByTagName(e)[0];s.parentNode.insertBefore(t,s)}(window,
            document,'script','https://connect.facebook.net/en_US/fbevents.js');
        fbq('init', '926790474121839');
        fbq('track', 'PageView');
    </script>
    <noscript><img height="1" width="1" style="display:none"
                   src="https://www.facebook.com/tr?id=926790474121839&ev=PageView&noscript=1"
    /></noscript>
    <!-- DO NOT MODIFY -->
    <!-- End Facebook Pixel Code -->

    <!-- start Mixpanel -->
    <script type="text/javascript">(function(e,a){if(!a.__SV){var b=window;try{var c,l,i,j=b.location,g=j.hash;c=function(a,b){return(l=a.match(RegExp(b+"=([^&]*)")))?l[1]:null};g&&c(g,"state")&&(i=JSON.parse(decodeURIComponent(c(g,"state"))),"mpeditor"===i.action&&(b.sessionStorage.setItem("_mpcehash",g),history.replaceState(i.desiredHash||"",e.title,j.pathname+j.search)))}catch(m){}var k,h;window.mixpanel=a;a._i=[];a.init=function(b,c,f){function e(b,a){var c=a.split(".");2==c.length&&(b=b[c[0]],a=c[1]);b[a]=function(){b.push([a].concat(Array.prototype.slice.call(arguments,
        0)))}}var d=a;"undefined"!==typeof f?d=a[f]=[]:f="mixpanel";d.people=d.people||[];d.toString=function(b){var a="mixpanel";"mixpanel"!==f&&(a+="."+f);b||(a+=" (stub)");return a};d.people.toString=function(){return d.toString(1)+".people (stub)"};k="disable time_event track track_pageview track_links track_forms register register_once alias unregister identify name_tag set_config reset people.set people.set_once people.increment people.append people.union people.track_charge people.clear_charges people.delete_user".split(" ");
        for(h=0;h<k.length;h++)e(d,k[h]);a._i.push([b,c,f])};a.__SV=1.2;b=e.createElement("script");b.type="text/javascript";b.async=!0;b.src="undefined"!==typeof MIXPANEL_CUSTOM_LIB_URL?MIXPANEL_CUSTOM_LIB_URL:"file:"===e.location.protocol&&"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js".match(/^\/\//)?"https://cdn.mxpnl.com/libs/mixpanel-2-latest.min.js":"//cdn.mxpnl.com/libs/mixpanel-2-latest.min.js";c=e.getElementsByTagName("script")[0];c.parentNode.insertBefore(b,c)}})(document,window.mixpanel||[]);
    mixpanel.init("d09b033cd5f1e6f6233545b857eae501");</script>
    <!-- end Mixpanel -->

    <!-- Localizer Integration Code -->
    <script type="text/javascript" src="https://localizercdn.com/localizer.js"></script>
    <script>
        Localizer.init({
            siteId: 845463647,
            cacheall: true,
            detectnew: true
        });
    </script>






</head>
<body class="page-404-500 page-404-500--500 background--orange">


<header class="header">
    <div class="container-fluid pl24">
        <div class="header__menu-wrapper flex flex--justify-space-between flex--align-bottom">
            <a href="/" class="header__logo logo-offset">
                <img src="/landing/images/logo/fomo-logo-purple.svg" alt="Fomo Logo">
            </a>
        </div>
    </div>
</header>

<div class="page-404-500__wrapper">
    <div class="page-404-500__image">
        <img src="/landing/images/landing/500.svg" alt="500 image">
    </div>
</div

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.