dongran1779 2015-11-04 10:46
浏览 239

PHP使用CURL发布八位字节流

I try to follow this sample in PHP https://msdn.microsoft.com/library/windows/apps/xaml/hh868252.aspx

What will be the equivalent of this peace of code in PHP?

byte[] contentInBytes = Encoding.UTF8.GetBytes(xml);
...
using (Stream requestStream = request.GetRequestStream())
            requestStream.Write(contentInBytes, 0, contentInBytes.Length);

If i try this, this is not working

$sendPush = curl_init();
curl_setopt($sendPush, CURLOPT_URL, $uri);  
curl_setopt($sendPush, CURLOPT_HEADER, true);
$headers = array('Content-Type: text/xml',"Content-Type: text/xml","X-WNS-RequestForStatus:true", "X-WNS-Type:wns/toast","Content-Length: " . strlen($toastMessage) ,"X-WindowsPhone-Target: toast","Authorization: Bearer $accessToken");
curl_setopt($sendPush, CURLOPT_HTTPHEADER, $headers);
curl_setopt($sendPush, CURLOPT_RETURNTRANSFER, true);
curl_setopt($sendPush,CURLOPT_POST, true);
curl_setopt($sendPush, CURLOPT_POSTFIELDS, $toastMessage);
$output = curl_exec($sendPush);

Thanks for your help

  • 写回答

1条回答 默认 最新

  • duancutan4770 2015-11-05 08:07
    关注

    The problem wasn't from CURL but from the $toastMessage string. If you want to send WPS notifications, you need to use one of the format describe here https://msdn.microsoft.com/en-us/library/windows/apps/hh761494.aspx?f=255&MSPPError=-2147217396

    评论

报告相同问题?

悬赏问题

  • ¥100 任意维数的K均值聚类
  • ¥15 stamps做sbas-insar,时序沉降图怎么画
  • ¥15 unity第一人称射击小游戏,有demo,在原脚本的基础上进行修改以达到要求
  • ¥15 买了个传感器,根据商家发的代码和步骤使用但是代码报错了不会改,有没有人可以看看
  • ¥15 关于#Java#的问题,如何解决?
  • ¥15 加热介质是液体,换热器壳侧导热系数和总的导热系数怎么算
  • ¥100 嵌入式系统基于PIC16F882和热敏电阻的数字温度计
  • ¥15 cmd cl 0x000007b
  • ¥20 BAPI_PR_CHANGE how to add account assignment information for service line
  • ¥500 火焰左右视图、视差(基于双目相机)