hi,

I try to create a php server to send message with c2dn.
The process is very slow, It take more than 10 min to send 5000
messages.

the code is very simple:
First I connect to google:
        $this->ch = curl_init();
         $post_fields = "accountType=" . urlencode('GOOGLE') .
"&Email=" . urlencode($username) . "&Passwd=" . urlencode($password) .
"&source=" . urlencode($source) . "&service=" . urlencode($service);

        curl_setopt($this->ch, CURLOPT_URL, "https://www.google.com/
accounts/ClientLogin");
        curl_setopt($this->ch, CURLOPT_HEADER, true);
        curl_setopt($this->ch, CURLOPT_POST, true);
        curl_setopt($this->ch, CURLOPT_POSTFIELDS, $post_fields);
        curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($this->ch, CURLOPT_FRESH_CONNECT, true);

        curl_setopt($this->ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
        curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($this->ch, CURLOPT_TIMEOUT, 10);
        curl_setopt($this->ch, CURLOPT_CONNECTTIMEOUT, 10);

        $response = curl_exec($this->ch);


After login, I send the message to each users with the same
connection :

while($deviceToken){
        $post_fields = "xxxxxx&collapse_key=aaaa"  .
"&data.message=" . urlencode($message);
        curl_setopt($this->ch, CURLOPT_URL, "http://
android.apis.google.com/c2dm/send");
        curl_setopt($this->ch, CURLOPT_HTTPHEADER, $headers);
        curl_setopt($this->ch, CURLOPT_SSL_VERIFYPEER, false);
        curl_setopt($this->ch, CURLOPT_POST, true);
        curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($this->ch, CURLOPT_POSTFIELDS,
"registration_id=" . $deviceToken.$post_fields);
        $result=curl_exec($this->ch);
}

Somebody know a better (faster) way to do the job?


-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
android-developers+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en

Reply via email to