小编Ali*_*ani的帖子

为什么我的授权标头在Guzzle中给我401?

我在Guzzle 4.2上收到401,并且在Postman上也可以使用相同的设置。下面的代码。

// Create a client with a base URL
    $client = new GuzzleHttp\Client(['base_url' => 'cloud.feedly.com/v3/streams/contents?streamId=user/user-id/category/global.all&count=1']);

    // Send a request to https://github.com/notifications
    $response = $client->get();

    //Auth
   $response->addHeader('Authorization', "auth-code");


    //send
    $r = $response->send();

   dd($r->json());
Run Code Online (Sandbox Code Playgroud)

错误是:

GuzzleHttp \ Exception \ ClientException (401) 
Client error response [url] cloud.feedly.com/v3/streams/contents?streamId=user/user-id/global.all&count=1 [status code] 401 [reason phrase] Unauthorized
Run Code Online (Sandbox Code Playgroud)

php guzzle

3
推荐指数
1
解决办法
1万
查看次数

How to delay execution of script while using Laravel's chunk feature?

I am trying to delay the execution of a script by a few seconds after it processes say 200 records using Laravel's chunk method. Here's what I've right now. Should I put a counter somewhere? But then that will not work I believe, are there other techniques?

    Article::chunk(200, function ($articles)
    { 
        foreach ($articles as $article)
        {

        }

    });
Run Code Online (Sandbox Code Playgroud)

Thanks to WereWolf, it worked. Can't believe it was so simple.

[2014-08-27 07:18:23] local.INFO: Article metrics:198 [] []
[2014-08-27 07:18:24] local.INFO: Article …
Run Code Online (Sandbox Code Playgroud)

php laravel

3
推荐指数
1
解决办法
6294
查看次数

为什么我的代码在几个阶段返回错误的密钥?

为什么我会在返回的数据中得到差异.它工作正常,直到3,然后繁荣,它混乱到最后.我在做什么很简单.我从带有id,name的txt文件中获取值,并将id与另一个具有name,name的txt文件匹配,使其看起来像id,id,如下所示.但是,它并不像您期望的那样有效.匹配正在进行,直到它搞砸了.

0,1
1,3
0,2
0
3,0,4
2
3,0
4,2
4,1
2,




while ((output2 = br2.readLine()) != null) {

    String[] vv = output2.split(",");
    String value1 = vv[0];
    String value2 = vv[1];

    for (Map.Entry<Integer, String> entry : map.entrySet()) {
        int key = entry.getKey();
        String value = entry.getValue();
                                    //System.out.println(key+","+value);

        if ((value1.equals(value))) {
            System.out.print(key + ",");

        }

        if ((value2.equals(value))) {
            System.out.print(key + "\n");
        }

    }

}
Run Code Online (Sandbox Code Playgroud)

数据

ids.txt

0,Triple H
1,John Cena
2,Megan Fox
3,The Undertaker
4,Pamela Anderson
5,The Rock
Run Code Online (Sandbox Code Playgroud)

的text.txt

Triple H,John Cena …
Run Code Online (Sandbox Code Playgroud)

java

2
推荐指数
1
解决办法
87
查看次数

如果没有一堆if else语句,我怎么能写这个函数呢?

我基本上只是想不出这个,不想破解它.

如果我这样做一年52周就会显得那么混乱.

有小费吗?

更新

这个问题与获得当年的本周无关.

这个问题是关于自定义日期以来已过去几周的问题.

我希望下周的训练能够在本周的第6天出现;)

我开始的日子是99:2018-05-30 18:39:29.

你的一些例子在第15周向我展示.

然而,我的代码显示了第16周,这是正确的.看到警告?

  calculateUsersCurrentWorkoutWeek: function(timestamp) {
            let daysSinceSignup = moment().diff(timestamp, "days");
            if (daysSinceSignup <= 6) {
              return 1;
            } else if (daysSinceSignup > 6 && daysSinceSignup <= 13) {
              return 2;
            } else if (daysSinceSignup > 13 && daysSinceSignup <= 20) {
              return 3;
            } else if (daysSinceSignup > 20 && daysSinceSignup <= 27) {
              return 4;
            } else if (daysSinceSignup > 27 && daysSinceSignup <= 34) {
              return 5;
            } …
Run Code Online (Sandbox Code Playgroud)

javascript

2
推荐指数
1
解决办法
174
查看次数

标签 统计

php ×2

guzzle ×1

java ×1

javascript ×1

laravel ×1