【问题标题】:Grabbing Device Tokens from Urban Airship从 Urban Airship 获取设备代币
【发布时间】:2014-11-12 08:52:32
【问题描述】:

如果有人在关闭免费推送系统时离开 Urban Airship,那么毫无疑问,您希望从他们的服务器中获取设备令牌。如果是这样的话,希望这会对你有所帮助......

【问题讨论】:

    标签: php curl push-notification urbanairship.com


    【解决方案1】:
     <?php
    
    $appKey = '<Your App Key>';
    $appSecret = '<Your App Master Secret>';
    
    $fetchedDeviceTokens = array();
    
    $url = "https://go.urbanairship.com/api/device_tokens/";
    
    for ($x=0; $x<=100000; $x++) {
    
        $curl = curl_init($url);
        curl_setopt($curl, CURLOPT_HEADER, false);
        curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
        curl_setopt($curl, CURLOPT_HTTPHEADER, array("Content-type: application/json"));
        curl_setopt($curl, CURLOPT_POST, false);
        curl_setopt($curl, CURLOPT_USERPWD, $appKey .":".$appSecret); 
    
        $json_response = curl_exec($curl);
    
        $res = json_decode($json_response);
        $nextURL = $res->next_page;   
    
        $deviceTokensObjectArray = $res->device_tokens;
    
        foreach($deviceTokensObjectArray as $val){
            $deviceToken = $val->device_token;
            $fetchedDeviceTokens[] = $deviceToken;
        }
    
        if($nextURL){
            $url = $nextURL;
        }
        else{
            break;
        }    
    } 
    
    foreach($fetchedDeviceTokens as $val){
    
    //USE THIS LOOP TO INSERT INTO YOR DATABASE OR CREATE AN XML ETC.
    
     }
    
    ?>
    

    【讨论】:

      【解决方案2】:

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-11-27
        • 1970-01-01
        • 2015-08-16
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多