douxun2023 2016-08-26 07:35
浏览 29
已采纳

too long

I started following this github tutorial It successfully GET all entries and POST data to a form. So after that as I move forward I wanted to add search filters with my GET call. After a lot of researching and trying different approaches I get to the point that I always get

{
status: 401,
response: "Permission denied"
}

as my JSON response. Following this I implemented search but it didn't work: https://www.stevenhenty.com/gravity-forms-api/#filter_entries
By consulting some php people they told me it's permission issue your call is correct. So I went here and tried both methods WordPress Cookie Authentication and External Clients: Signature Authentication but the response is the same.

I'm using the Cookie NSString *string = [NSString stringWithFormat:@"%@%@?_gf_json_nonce=%@",BaseURLString,route,[[NSUUID UUID] UUIDString]]; The _gf_json_nonce after searching I got that it'll be the UDID of the phone so that is why I'm using that.
If I use the other signature one I use it as NSString *string = [NSString stringWithFormat:@"%@%@?api_key=%@&signature=%@&expires=%@",BaseURLString,route,api_key,signature,expires]; the result is the same.
So if I want to use any of this call with search filters I'm doing this

NSDictionary *params = @{@"key": @"2",
                             @"value": @"my@email.com",
                             @"operator": @"contains"};

    NSMutableDictionary *modify = [NSMutableDictionary new];
    [modify  setObject:params forKey:@"field_filters"];


    [manager GET:stringURL  parameters:modify progress:nil success:^(NSURLSessionTask *task, id responseObject) {

So any ideas how to get it authenticate so that the call can start working.

UPDATE
1: I have also tried this but it didn't work. I've also commented on it.

  • 写回答

1条回答 默认 最新

  • douyan4243 2016-09-01 09:26
    关注

    Make sure you have the search param set to a URL encoded JSON string like this:

    http://yourdomain/gravityformsapi/forms/3/entries/?api_key=[snip]&signature=[snip]%3D&expires=[snip]&search={%22field_filters%22:%20[{%22key%22:%20%222%22,%20%22value%22%20:%20%@gmailcom%22,%20%22operator%22%20:%20%22contains%22}]}
    

    So, a bit easier to read, the search param would look something like this:

    {
      "field_filters": [
        {
          "key": "2",
          "value": "@gmail.com",
          "operator": "contains"
        }
      ]
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 微信会员卡等级和折扣规则
  • ¥15 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分