Your server seems to be blocking communication with the paypal server. The issue might not be with the code at all.
I created a sample page /untitled.php that tries to communicate with the webassist server and that won't work either. You may need to contact your hosting provider and ask why curl isn't able to communicate with the paypal server. You may need to enable something on the server admin control panel.