The Community Forums

Interact with an entire community of cPanel & WHM users!
  1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Google gcm and curl question

Discussion in 'Security' started by upsforum, Jul 19, 2014.

  1. upsforum

    upsforum Well-Known Member

    Joined:
    Jul 27, 2005
    Messages:
    446
    Likes Received:
    0
    Trophy Points:
    16
    I have 2 vps that apparently they they have the same configuration:

    centos 6.5
    cpanel 11.44
    suphp
    csf/lfd (identical configuration)
    mod_security
    etc.etc....

    the problem is that a script for push messages return 401 error on first vps and 200 in second vps

    both ip added in whitelist of gcm service

    first vps return:

    PHP:
    HTTP/1.1 401 Unauthorized
    Content
    -Typetext/htmlcharset=UTF-8
    Date
    Sat19 Jul 2014 11:51:41 GMT
    Expires
    Sat19 Jul 2014 11:51:41 GMT
    Cache
    -Control: private, max-age=0
    X
    -Content-Type-Optionsnosniff
    X
    -Frame-OptionsSAMEORIGIN
    X
    -XSS-Protection1mode=block
    Server
    GSE
    Alternate
    -Protocol443:quic
    Transfer
    -Encodingchunked
    second vps return:

    PHP:
    HTTP/1.1 200 OK
    Content
    -Typeapplication/jsoncharset=UTF-8
    Date
    Sat19 Jul 2014 11:43:44 GMT
    Expires
    Sat19 Jul 2014 11:43:44 GMT
    Cache
    -Control: private, max-age=0
    X
    -Content-Type-Optionsnosniff
    X
    -Frame-OptionsSAMEORIGIN
    X
    -XSS-Protection1mode=block
    Server
    GSE
    Alternate
    -Protocol443:quic
    Transfer
    -Encodingchunked

    the script is:

    PHP:
    <?php
            define
    ("GOOGLE_API_KEY""xxxxxxxxxxxxx");
            
    define("GOOGLE_GCM_URL""https://android.googleapis.com/gcm/send");

            function 
    send_gcm_notify($reg_id$message$spedizione) {
                    
    $fields = array(
                            
    'registration_ids'  => array( $reg_id ),
                            
    'data'              => array( "shipment" => $message"numtrack" => $spedizione ),
                    );
                    
    $headers = array(
                            
    'Authorization: key=' GOOGLE_API_KEY,
                            
    'Content-Type: application/json'
                    
    );
                    
    $ch curl_init();
                    
    curl_setopt($chCURLOPT_URLGOOGLE_GCM_URL);
                    
    curl_setopt($chCURLOPT_POSTtrue);
                    
    curl_setopt($chCURLOPT_HTTPHEADER$headers);
                    
    curl_setopt($chCURLOPT_RETURNTRANSFERtrue);
                    
    curl_setopt($chCURLOPT_SSL_VERIFYPEERfalse);
                    
    curl_setopt($chCURLOPT_POSTFIELDSjson_encode($fields));
                    
    $result curl_exec($ch);

                    if (
    $result === FALSE) {
                            die(
    'Problem occurred: ' curl_error($ch));
                    }
                    
    curl_close($ch);
                    echo 
    "$result<br><br>";
             }


    send_gcm_notify("xxxxxxxxxxxxxxxxxxxxxxxx""ok""1");
     
  2. cPanelMichael

    cPanelMichael Forums Analyst
    Staff Member

    Joined:
    Apr 11, 2011
    Messages:
    30,811
    Likes Received:
    669
    Trophy Points:
    113
    cPanel Access Level:
    Root Administrator
    Hello :)

    Have you checked with Google's support to see if they are able to troubleshoot the issue further based on the output you provided?

    Thank you.
     
Loading...

Share This Page