使用python请求branch.io API

使用python请求branch.io API,python,branch.io,Python,Branch.io,我需要请求分支io API,但是文档丢失了一点 我需要为每个用户获得一个深度链接,这取决于他们的用户ID(这是唯一的标准)。 我该怎么做 非常感谢 实际代码,当我更改用户ID时,它为我提供了一个始终相同的链接: import requests import csv import sys import urllib import json #Constants getrequest = "https://api2.branch.io/v1/url" dic_test = { "b

我需要请求分支io API,但是文档丢失了一点

我需要为每个用户获得一个深度链接,这取决于他们的用户ID(这是唯一的标准)。 我该怎么做

非常感谢

实际代码,当我更改用户ID时,它为我提供了一个始终相同的链接:

import requests
import csv
import sys
import urllib
import json

#Constants
getrequest = "https://api2.branch.io/v1/url"
dic_test = {
        "branch_key": 'my_key_test',
        "user": {
            "userid": 40
        }
    }
test = requests.post(getrequest, data = dic_test)

# Always the same link
print(json.loads(test.text))

为不同的用户ID获取新链接的正确方法是:

getrequest = "https://api2.branch.io/v1/url"
dict_test = json.dumps({
    "branch_key": '<branch_key>',
    "data": {
        "$deeplink_path": "/<path_to_open_link>/", "user_id": "<user_id>"
    }
})
headers = {'Content-Type': 'application/json'}
test = requests.post(getrequest, headers=headers, data=dict_test)
getrequest=”https://api2.branch.io/v1/url"
dict_test=json.dumps({
“分支密钥”:“”,
“数据”:{
“$deeplink_path”:“/”,“用户id”:”
}
})
headers={'Content-Type':'application/json'}
test=requests.post(getrequest,headers=headers,data=dict\u test)

根据您的要求,数据键可以有不同的参数。Json.dump(dict_test)和头是必需的

为不同的用户ID获取新链接的正确方法是:

getrequest = "https://api2.branch.io/v1/url"
dict_test = json.dumps({
    "branch_key": '<branch_key>',
    "data": {
        "$deeplink_path": "/<path_to_open_link>/", "user_id": "<user_id>"
    }
})
headers = {'Content-Type': 'application/json'}
test = requests.post(getrequest, headers=headers, data=dict_test)
getrequest=”https://api2.branch.io/v1/url"
dict_test=json.dumps({
“分支密钥”:“”,
“数据”:{
“$deeplink_path”:“/”,“用户id”:”
}
})
headers={'Content-Type':'application/json'}
test=requests.post(getrequest,headers=headers,data=dict\u test)
根据您的要求,数据键可以有不同的参数。dumps(dict_test)和头是必需的

这是我的代码示例

@receiver(pre\u save,sender=Story,dispatch\u uid=“get\u deep\u link”)
def get_deep_链接(发送方,实例,**kwargs):
分支点=”https://api2.branch.io/v1/url"
标题={“内容类型”:“应用程序/json”}
测试数据={
“分支密钥”:分支密钥,
“数据”:{
“类型”:“故事\项目\页面”,
“实体id”:instance.id,
“页码id”:2228
}
}
post\u request=requests.post(branchendpoint,headers=headers,json=test\u数据)
jsonData=json.loads(post_request.text)
instance.deep_link=f”“
这是我的代码示例

@receiver(pre\u save,sender=Story,dispatch\u uid=“get\u deep\u link”)
def get_deep_链接(发送方,实例,**kwargs):
分支点=”https://api2.branch.io/v1/url"
标题={“内容类型”:“应用程序/json”}
测试数据={
“分支密钥”:分支密钥,
“数据”:{
“类型”:“故事\项目\页面”,
“实体id”:instance.id,
“页码id”:2228
}
}
post\u request=requests.post(branchendpoint,headers=headers,json=test\u数据)
jsonData=json.loads(post_request.text)

instance.deep_link=f”“
要清楚,您是只请求链接()还是创建API请求以使用python检索数据。我请求每个用户的链接,使用python,具体取决于用户ID显示您迄今为止的尝试!完成。现在,我有一个链接,但总是相同的,使用不同的ID。当您将40更改为41时,不会发生任何事情吗?要清楚的是,您是只要求链接()还是创建API请求以使用python检索数据。我要求每个用户的链接,使用python,具体取决于用户ID显示您迄今为止的尝试!完成。现在,我有一个链接,但始终是相同的,不同的ID当您将40更改为41时,是否什么都没有发生?