PHP CURL GET / POST摘要式身份验证

时间:2015-08-08 10:31:56

标签: php authentication curl digest digest-authentication

我使用curl方法从REST API获取数据。 API需要摘要验证。我已经完成了摘要身份验证但不适用于post方法。适用于GET方法。

import Tkinter
class Application(Tkinter.Frame):
    def mygrab(self):
        print "grab is ok"
        root.grab_set_global()

    def createWidgets(self):
        self.QUIT = Tkinter.Button(self)
        self.QUIT["text"] = "QUIT"
        self.QUIT["command"] =  self.quit
        self.QUIT.pack({"side": "left"})
        self.grab = Tkinter.Button(self)
        self.grab["text"] = "Grab",
        self.grab["command"] = self.mygrab
        self.grab.pack({"side": "left"})        

    def __init__(self, master=None):
        Tkinter.Frame.__init__(self, master)
        self.pack()
        self.createWidgets()

root = Tkinter.Tk()
app = Application(master=root)
app.mainloop()
root.destroy()`

响应说,404表示找不到网址。但URL是正确的。

cURL信息7.40.0

提前致谢。

2 个答案:

答案 0 :(得分:1)

感谢@ Sufi,POST请求的工作代码(如果其他人需要此代码):

d-block

答案 1 :(得分:0)

使用get_headers($url)而不是第一次卷曲。

在标题中添加Content-Type:application / json。

$request_header[] = 'Content-Type:application/json';之后添加$request_header = array($request)这一行。

相关问题