好了#1,你可以做這樣的事情...
有一個方法,在手機應用程式,例如:
- (void) send_to_server {
NSString *urlString = [NSString stringWithFormat:@"http://weburl.com/?variable=%@", variable];
NSURLRequest *theRequest = [NSURLRequest requestWithURL:[NSURL URLWithString:urlString] cachePolicy:NSURLRequestUseProtocolCachePolicy timeoutInterval:60.0];
NSURLConnection *theConnection = [[NSURLConnection alloc] initWithRequest:theRequest delegate:self];
if (theConnection) {
receivedData = [NSMutableData data];
if ([[NSString stringWithFormat:@"%@", receivedData] isEqualToString:@"Success"]){
//Do something here
}else{
//Do something else here
}
}
}
在你的PHP,你可以這樣做:
<?php
$variable = $_GET['variable'];
//do what you need to do here...
//Put things into queue or what-not
if ($success){
echo "Success";
}else{
echo "Failure";
}
?>
更新
<?php
if (isset($_GET['variable']){
echo "Success";
$variable = $_GET['variable'];
//do what you need to do here...
}else{
echo "Failure";
}
?>
至於發送推送通知到其他手機,我不知道該怎麼做。但我會認爲PHP不會有效率問題。
感謝您的信息。所以根據Gearman的說法,我應該編寫一個接受請求的PHP腳本,將繁重的工作傳遞給Gearman Job Server(不會在PHP中)並返回響應。這樣的應用程序不會等待響應..是嗎? 我正在使用的數據庫是MySQL,我不太確定,如果我知道一種語言,可以很好地處理MySQL數據庫,併發送推送通知從數據庫中存在的令牌 – proctr
您是正確的,但你可以使用PHP來寫工人。我將更新答案,以澄清 –