【发布时间】:2015-03-07 01:25:10
【问题描述】:
我正在尝试从 PHP 更新通知 HUB 注册。 在这里,他们展示了如何从 PHP 发送通知: http://azure.microsoft.com/en-us/documentation/articles/notification-hubs-php-backend-how-to/
我尝试以这种方式调整代码以使用其他 API 方法: https://msdn.microsoft.com/en-us/library/azure/dn223262.aspx
public function updateRegistration($registrationId) {
# build uri
$uri = $this->endpoint . $this->hubPath . "/registrations/" . $registrationId . NotificationHub::API_VERSION;
$ch = curl_init($uri);
$contentType = "application/atom+xml;type=entry;charset=utf-8";
$token = $this->generateSasToken($uri);
$headers = [
'Authorization: '.$token,
'Content-Type: '.$contentType,
'x-ms-version: 2013-08',
'If-Match: update'
];
curl_setopt_array($ch, array(
CURLOPT_POST => TRUE,
CURLOPT_RETURNTRANSFER => TRUE,
CURLOPT_SSL_VERIFYPEER => FALSE,
CURLOPT_HTTPHEADER => $headers,
CURLOPT_POSTFIELDS => '<?xml version="1.0" encoding="utf-8"?>
<entry xmlns="http://www.w3.org/2005/Atom">
<content type="application/xml">
<WindowsRegistrationDescription xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/netservices/2010/10/servicebus/connect">
<Tags>myTag, myOtherTag</Tags>
</WindowsRegistrationDescription>
</content>
</entry>'
));
// Send the request
$response = curl_exec($ch);
// Check for errors
if($response === FALSE){
throw new Exception(curl_error($ch));
}
$info = curl_getinfo($ch);
if ($info['http_code'] <> 201) {
throw new Exception('Error :'. $info['http_code'] . ' msg: ' . $response);
}
}
但我收到此错误:
“错误:405 消息:405指定的 HTTP 动词 (POST) 无效。”
我做错了什么?
谢谢!
【问题讨论】:
标签: php azure notifications