Notify_API.php - $response is null?
  • mriksmanmriksman September 2010

    I have grabbed the library from github, and tried to see what the $response was by using print_R($response). All I get is;

    null

    What am I doing wrong with my request? I have entered the username and key of my notifo account, and filled out the 'title', 'msg', and 'uti' of the $params array.

    print_R($notifo) gives;

    Notifo_API Object
    (
    [apiUsername:protected] => ......
    [apiSecret:protected] => xd92ef9......
    )

    As expected. print_R($params) gives expected results. But print_R($response) gives null??

    Thoughts?

  • jazzychadjazzychad September 2010

    What function are you trying to print the results of? I just tested it out locally and got "{"status":"success","response_code":2201,"response_message":"OK"}" doing a print_r on the return value of $notifo->send_notification($params);

    EOL

  • mriksmanmriksman September 2010

    That is what I am expecting to get - but I get null.

    I have not changed the variable names, so they are identical to the library given. Thus, $response is the return value of $notifo->send_notification($params)

    I even put print_R statments in the Notifo_API.php library itself to see if any data was incorrect. In the function sendRequest(), $url seems ok, as does $data. But after the curl commands, the return value of $result = curl_exec($ch) is null.

    When I do a test with this code;

    <?php<br /> error_reporting(E_ALL);
    ini_set('display_errors', '1');
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL,
    'http://news.google.com/news?output=rss');
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
    $contents = curl_exec ($ch);
    echo $contents;
    curl_close ($ch);
    ?>

    it correctly returns Google's RSS feed.

    Would it have anything to do with SSL? I have the SSL port open, but it is in use on another webserver setup. (hostname: www.abc.com.au has it, and this request is coming from control.abc.com.au - two different instances in IIS).

    Even if I didn't get a response (due to some strange SSL forwarding happening), wouldn't the notification still proceed? Or is there some two-way comms before it does?

  • jazzychadjazzychad September 2010

    Might be an SSL verification problem. Do you have the root CA certs installed on your server?

    What happens if you add these lines to the curl options:

    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

    EOL

  • mriksmanmriksman September 2010

    I have no idea! I went through GoDaddy, and I did whatever they told me to do! (I know what I need to know, so a lot of the things I do on my webserver are forgotten very quickly!) How would I go about checking this?

    Freakin amazing! Adding those two lines worked, and I am getting proper responses, and the notification on my phone is working!

    So, what did these lines do, what is the problem with having them there, and what should I do different?

    Thanks!

  • jazzychadjazzychad September 2010

    If you are making a call to an https url, curl will (by default) check to make sure that the url's ssl certificate is trusted by the root certificate authorities. To do this, the root certificate authorities' certs need to be installed locally on the server. If this check fails, then curl will bail on the request and return null. Adding those two lines tells curl not to worry about those checks and make the request anyway. You normally add those lines if you a) trust the end site, and b) don't have the ability to install the root CA certs on your server (if you are using a shared host, for example).

    EOL

  • mriksmanmriksman September 2010

    Oh right! So in this case it is OK - because I trust notifo! (I think...)

    This is such a cool app!

    Thanks for your help :)

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Sign In Apply for Membership

In this Discussion