PHP

cURL

tags : haxe,php,curl

I made this small haXe type signature for cURL that I use in aproject.

I think it could be improved but for now it works fine.

Usage

This is a small snippet that i use in a project where I try to get logged in to my Google Analytics account via cURL :


this.email = email;
this.password = pwd;
this.ids = id;

var ch = Curl.init();
var data = {accountType:'GOOGLE';
            Email:this.email,
            Passwd:this.password,
            source:'CLI_GAnalytics',
            service:'analytics'
            };
Curl.setopt(ch, CurlOpt.URL, 'https://www.google.com/accounts/ClientLogin');
Curl.setopt(ch, CurlOpt.FOLLOWLOCATION, true);
Curl.setopt(ch, CurlOpt.SSL_VERIFYPEER, 0);
Curl.setopt(ch, CurlOpt.POST, true);
Curl.setopt(ch, CurlOpt.RETURNTRANSFER, true);
Curl.setopt(ch, CurlOpt.POSTFIELDS, data);

var hasil = Curl.exec(ch);
var res = hasil.split('Auth=');

Curl.close(ch);

this.auth = res[1];	

Sources code :

I hosted them here https://code.google.com/p/haxe-curl/source/browse/#svn/trunk.

If you want to see a real usage of this class check this project GAnalytics.