gpt4 book ai didi

service - 推送通知的反馈服务

转载 作者:行者123 更新时间:2023-12-02 12:04:29 24 4
gpt4 key购买 nike

我编写了以下脚本来读取反馈数据。但是,由于某些原因,我没有从服务器收到任何数据。您能告诉我脚本有什么问题吗?另外,如果您有任何可用于反馈服务的php脚本,请您分享一下...

问候,DD。

 <?php

$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', 'ck.pem');


// Set time limit to indefinite execution
set_time_limit (0);

// Set the ip and port we will listen on
$address = 'ssl://feedback.sandbox.push.apple.com';
$port = 2196;

// Create a TCP Stream socket
$sock = socket_create(AF_INET, SOCK_STREAM, SOL_TCP);
echo "PHP Socket Server started at " . $address . " " . $port . "\n";

// Bind the socket to an address/port
socket_bind($sock, $address, $port) or die('Could not bind to address');
// Start listening for connections
socket_listen($sock);

//loop and listen

while (true) {
/* Accept incoming requests and handle them as child processes */
$client = socket_accept($sock);

// Read the input from the client – 1024 bytes
$input = socket_read($client, 1024);


}

// Close the client (child) socket
socket_close($client);

// Close the master sockets
socket_close($sock);

?>

最佳答案

您必须充当客户端,就像发送通知一样。那一定是这样的:

<?php
$certFile = 'apns-dev.pem';

while (true) {
$ctx = stream_context_create();
stream_context_set_option($ctx, 'ssl', 'local_cert', $certFile);
//stream_context_set_option($ctx, 'ssl', 'passphrase', $this->certPass);
echo "try to open stream\n";
$fp = stream_socket_client('ssl://feedback.sandbox.push.apple.com:2196', $err, $errstr, 5, STREAM_CLIENT_CONNECT, $ctx);
if (!$fp) {
print "Failed to connect". $err . $errstr. "\n";
exit();
} else {
echo 'Connected to feedback sandbox...';
while (($in = fread($fp, 1024)) != EOF) {
echo 'read '. $in . "\n";
}

socket_close($fp);
fclose($fp);
}
sleep(2000);
}
?>

关于service - 推送通知的反馈服务,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1708248/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com