doufu5521 2009-08-19 22:28
浏览 69
已采纳

带有从iphone到PHP脚本的自定义标头的HTTP POST。 你怎么读标题?

This code works, and I can see the request go out to my php script through charles with my custom header GUID attached.

NSMutableURLRequest *loginRequest = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:feedURLString]];
        NSData *myRequestData = [NSData dataWithBytes:[myRequestString UTF8String]length:[myRequestString length]];

    [ loginRequest setHTTPMethod: @"POST" ];
    [ loginRequest setHTTPBody: myRequestData ];
    [ loginRequest setValue:@"application/x-www-form-urlencoded" forHTTPHeaderField:@"content-type"];
    [ loginRequest setValue:@"testdatainguid" forHTTPHeaderField:@"GUID" ];

In php, I tried to read the header

    if(isset($_SERVER['GUID']))
{
    echo($_SERVER['GUID']);
}

I don't get any response. I tried getheaders, $_POST, $_GET and anything else I could think of, but I can't seem to get that data in my php. Any help would be greatly appreciated.

  • 写回答

2条回答 默认 最新

  • duanfu1873 2009-08-19 22:30
    关注

    I'd expect it in $_SERVER['HTTP_GUID'], as other HTTP headers are.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 shape_predictor_68_face_landmarks.dat
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料
  • ¥15 使用R语言marginaleffects包进行边际效应图绘制