使用 curl 上传 Dailymotion 视频
Dailymotion video upload using curl
我正在尝试使用 curl 从 google 驱动器获取视频到日常运动。我是新手。
我首先登录使用:curl --user name:password http://www.dailymotion.com/ 然后按照指南
有了这个:
curl --request POST \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--form 'url=<VIDEO_URL>' \
--form 'title=Dailymotion cURL upload test' \
--form 'tags=dailymotion,api,sdk,test' \
--form 'channel=videogames' \
--form 'published=true' \
"api url"
但它给我错误 "code":400,"message":"Invalid Authorization header format." 谁能帮忙?
您如何获得访问令牌?您的代码看起来有效,但鉴于错误消息,您的访问令牌一定不正常。在您提供的代码中,您必须将 ${ACCESS_TOKEN}
替换为实际的访问令牌。
要获取访问令牌,您可以:
- 要么按照此文档进行身份验证 https://developer.dailymotion.com/api#authentication
- 或者您可以简单地从 API 资源管理器 https://developer.dailymotion.com/tools
中测试创建一个
试试这个:
curl -v https://api.dailymotion.com/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=password" \
-d "client_id=<API_KEY>" \
-d "client_secret=<API_SECRET>" \
-d "username=<USER_USERNAME>" \
-d "password=<USER_PASSWORD>"
您的 ACCESS_TOKEN 将在 json 中生成:
{
"access_token": "YOUR ACCESS_TOKEN",
"token_type": "Bearer",
"expires_in": 36000,
"refresh_token": "xxxxxxxxxxx",
"scope": "read",
"uid": "Your uid"
}
复制生成的 access_token 字段并将其用于您的模式。
curl -H "Authorization: Bearer YOUR ACCESS_TOKEN" \
"https://api.dailymotion.com/file/upload"
我正在尝试使用 curl 从 google 驱动器获取视频到日常运动。我是新手。
我首先登录使用:curl --user name:password http://www.dailymotion.com/ 然后按照指南 有了这个:
curl --request POST \
--header "Authorization: Bearer ${ACCESS_TOKEN}" \
--form 'url=<VIDEO_URL>' \
--form 'title=Dailymotion cURL upload test' \
--form 'tags=dailymotion,api,sdk,test' \
--form 'channel=videogames' \
--form 'published=true' \
"api url"
但它给我错误 "code":400,"message":"Invalid Authorization header format." 谁能帮忙?
您如何获得访问令牌?您的代码看起来有效,但鉴于错误消息,您的访问令牌一定不正常。在您提供的代码中,您必须将 ${ACCESS_TOKEN}
替换为实际的访问令牌。
要获取访问令牌,您可以:
- 要么按照此文档进行身份验证 https://developer.dailymotion.com/api#authentication
- 或者您可以简单地从 API 资源管理器 https://developer.dailymotion.com/tools 中测试创建一个
试试这个:
curl -v https://api.dailymotion.com/oauth/token \
-H "Content-Type: application/x-www-form-urlencoded" \
-d "grant_type=password" \
-d "client_id=<API_KEY>" \
-d "client_secret=<API_SECRET>" \
-d "username=<USER_USERNAME>" \
-d "password=<USER_PASSWORD>"
您的 ACCESS_TOKEN 将在 json 中生成:
{
"access_token": "YOUR ACCESS_TOKEN",
"token_type": "Bearer",
"expires_in": 36000,
"refresh_token": "xxxxxxxxxxx",
"scope": "read",
"uid": "Your uid"
}
复制生成的 access_token 字段并将其用于您的模式。
curl -H "Authorization: Bearer YOUR ACCESS_TOKEN" \
"https://api.dailymotion.com/file/upload"