SSL certificate problem: self signed certificate in certificate chain

Go to http://curl.haxx.se/ca/cacert.pem and download the pem file and save in your php installation directory ( make sure while saving it retains the extension and not saved as a text file )

Now, open your php.ini file, scroll to the bottom and add the following line:

[cURL] 
curl.cainfo="D:\xampp\php\cacert.pem"

Replace D:\xampp\php\cacert.pem with the actual path.

https://laracasts.com/discuss/channels/laravel/how-to-solve-curl-error-60-ssl-certificate-in-laravel-5-while-facebook-authentication

http://stackoverflow.com/questions/17478283/paypal-access-ssl-certificate-unable-to-get-local-issuer-certificate

WebView-based Applications for Web Developers

Getting started with the Android WebView is fairly simple, whether you want load a remote URL or display pages stored in your app.

This tutorial walks you through creating a new Android Project, adding a WebView, loading a remote URL, and then loading a local HTML page.

https://developer.chrome.com/multidevice/webview/gettingstarted

Getting user location from an IP address

Want to retrieve information like the city, state, and country of a visitor from their IP address?

PHP example:

ip = $_SERVER['REMOTE_ADDR'];
$details = json_decode(file_get_contents("http://ipinfo.io/{$ip}"));
echo $details->city;

 

jQuery example:

$.get("http://ipinfo.io", function(response) {
    console.log(response.city);
}, "jsonp");

 

Source: http://stackoverflow.com/questions/409999/getting-the-location-from-an-ip-address#answer-17864552

PHP stdClass Object to Array

This post defines two ultra simple recursive function to convert multidimensional Objects to Arrays and multidimensional Arrays to Objects.

http://www.if-not-true-then-false.com/2009/php-tip-convert-stdclass-object-to-multidimensional-array-and-convert-multidimensional-array-to-stdclass-object/

NOTE: If this function is called as a class method, then the return line needs to be replaced with the following…

return array_map( array($this, __FUNCTION__), $d );

PHP implementation of Google Analytics

As you know the main implementation of GA is a JavaScript library which is all well and good as long as

  1. The user has JavaScript enabled
  2. Everything we want to track outputs html (so the GA code runs)

If we ever need to track page views and other events for a client who insists we catch that small minority of users with JavaScript turned off then we can us this

It can also be used in AJAX scripts and code that doesn’t actually display any html such as CSV export scripts.

https://developers.google.com/analytics/devguides/collection/gajs/methods/gaJSApiBasicConfiguration#_gat.GA_Tracker_._trackPageview

Get JSON from remote domain using jQuery when CORS not possible

The same origin policy means you cannot get data from a different server unless it allows cross-origin resource sharing (CORS).

To get round this restriction we can use the JSONP function of jQuery, however we do need to wrap the returning data in a javascript function specified by the initial request.

The 2 basic bits of code required are…

JQUERY:

$.ajax(
    {
        url: 'http://www.someotherdomain.com/json-feed.php',
        dataType: 'jsonp',
        success: function( data ){
        console.log( data ) ;
    }
});

PHP:

echo $_GET['callback'] . '(' .$aaMyJSONData . ');' ;

If the server allows CORS, you can send back the required headers using the following code:

if (isset($_SERVER['HTTP_ORIGIN'])) {
    header("Access-Control-Allow-Origin: {$_SERVER['HTTP_ORIGIN']}");
    header('Access-Control-Allow-Credentials: true');
    header('Access-Control-Max-Age: 86400'); // cache for 1 day
}