无法使用TwitterKit iOS SDK上传视频(错误请求:400)

时间:2016-06-28 21:57:12

标签: ios objective-c twitter cocoapods twitter-fabric

我正在尝试使用TwitterKit的内置方法“uploadMedia”将250 KB,500 x 500视频上传到Twitter;

但是我得到了400错误:

#!/usr/bin/python

from os import environ, path

from pocketsphinx.pocketsphinx import *
from sphinxbase.sphinxbase import *

MODELDIR = "../../../model"
DATADIR = "../../../test/data"

config = Decoder.default_config()
config.set_string('-hmm', path.join(MODELDIR, 'en-us/en-us'))
config.set_string('-lm', path.join(MODELDIR, 'en-us/en-us.lm.bin'))
config.set_string('-dict', path.join(MODELDIR, 'en-us/cmudict-en-us.dict'))
config.set_string('-logfn', '/dev/null')
decoder = Decoder(config)

stream = open(path.join(DATADIR, 'goforward.raw'), 'rb')
#stream = open('10001-90210-01803.wav', 'rb')

in_speech_bf = False
decoder.start_utt()
while True:
    buf = stream.read(1024)
    if buf:
        decoder.process_raw(buf, False, False)
        if decoder.get_in_speech() != in_speech_bf:
            in_speech_bf = decoder.get_in_speech()
            if not in_speech_bf:
                decoder.end_utt()
                print 'Result:', decoder.hyp().hypstr
                decoder.start_utt()
    else:
        break
decoder.end_utt()

要上传视频,我会获得本地文件的NSURL,将其转换为NSData,然后使用“multipart / form-data”作为内容类型调用该函数

Domain=TWTRNetworkingErrorDomain Code=-1011 "Request failed: bad request (400)" UserInfo={NSLocalizedFailureReason=, TWTRNetworkingStatusCode=400, NSErrorFailingURLKey=https://upload.twitter.com/1.1/media/upload.json, NSLocalizedDescription=Request failed: bad request (400)}, {
NSErrorFailingURLKey = "https://upload.twitter.com/1.1/media/upload.json";
NSLocalizedDescription = "Request failed: bad request (400)";
NSLocalizedFailureReason = "";
TWTRNetworkingStatusCode = 400;
}

我尝试了很多不同的东西,比如不同的视频格式,以及不同的内容类型。有没有人有这个工作的例子?

谢谢你, 加布

0 个答案:

没有答案