Wednesday, July 29, 2009

Wonder why Apache Web server is not working

Whether you are using Xamp, or Wamp and it does not work.

For example,
you get from Wamp: "Could not execute menu item (internal error) [Exception] Could not perform service action: the service has not been started."

Common mistake: Skype or IIS is running and it's occupying the 443 or 80 port.

You don't have to uninstall Skype, just
1) exit Skype
2) start wamp
3) start Skype again

Or setup skype using different port as follows Tools -> Options -> Advanced -> Connection -> Uncheck "Use port 80 or 443 as an alternative for..."

Wednesday, July 15, 2009

Generate WADL from API request and generate PHP, Ruby, Python, Java or C# code from WADL

Wonderful tool, you can find it in here:

http://tomayac.de/rest-describe/latest/RestDescribe.html

I get no response when using curl with SSL

PHP 5.2.9-2/Windows XP SP2

Fix:

add curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

Example:

Get all posts from Delicious:

$fetch_url ="https://api.del.icio.us/v1/posts/all?";
$curl = curl_init();
curl_setopt( $curl, CURLOPT_URL, $fetch_url );
curl_setopt( $curl, CURLOPT_RETURNTRANSFER, 1 );
curl_setopt( $curl, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt( $curl, CURLOPT_USERPWD,"username:password");
curl_setopt( $curl, CURLOPT_CONNECTTIMEOUT, 30 );
curl_setopt( $curl, CURLOPT_TIMEOUT,5 );
curl_setopt( $curl, CURLOPT_POST, 1 );
$response = curl_exec( $curl );
curl_close( $curl );
header("Content-Type:text/xml");
echo $response;