gpt4 book ai didi

api - 带有消息“传递的适配器不是HTTP连接适配器”的“Zend_Http_Client_Exception”

转载 作者:行者123 更新时间:2023-12-03 05:43:15 26 4
gpt4 key购买 nike

这让我发疯。我真的很讨厌发布问题,但是“这里去了”。

我能够使用Zend Gdata API for You Tube上传视频。 “一个视频” ...

自从我收到此错误:

Fatal error: Uncaught exception 'Zend_Http_Client_Exception' with message
'Passed adapter is not a HTTP connection adapter'
in ../pathtoapp/Zend/Http/Client.php:926

Stack trace:
#0 ../pathtoapp/Zend/library/Zend/Gdata/HttpClient.php(275): Zend_Http_Client->setAdapter(Object(__PHP_Incomplete_Class))
#1 ../pathtoapp/Zend/library/Zend/Gdata/App.php(692): Zend_Gdata_HttpClient->setAdapter(Object(__PHP_Incomplete_Class))
#2 ../pathtoapp/Zend/library/Zend/Gdata.php(219): Zend_Gdata_App->performHttpRequest('POST', 'http://uploads....', Array, Object(Zend_Gdata_MediaMimeStream), 'multipart/relat...', NULL)
#3 ../pathtoapp/Zend/library/Zend/Gdata/App.php(910): Zend_Gdata->performHttpRequest('POST', 'http://uploads....', Array, Object(Zend_Gdata_MediaMimeStream), 'multipart/relat...')
#4 /home/spotya/public_html/devblogpost/php/Zend/library/Zend/Gdata/App.php(985): Zend_Gdata_App-> in ../pathtoapp/Zend/library/Zend/Http/Client.php on line 926

我发现类似的帖子已经解决了该问题,但是他们的解决方案对我没有用。

我的代码:
error_reporting(E_ALL);
require_once('Zend/Loader.php');
require_once('../../includes/defines.php');

Zend_Loader::loadClass('Zend_Gdata_HttpClient');
$client = new Zend_Gdata_HttpClient();

$developerKey = '';
$applicationID = '';
$clientID = '';

$sql = "SELECT * FROM `you_tube_credentials` WHERE `user_id` = '1'";
$auth = $db->FetchAssoc($db->Query($sql));
if($auth['id'] == '') // If Auth Key not stored in DB get one
{
$authenticationURL= 'https://www.google.com/accounts/ClientLogin';
Zend_Loader::loadClass('Zend_Gdata_ClientLogin');
$httpClient = Zend_Gdata_ClientLogin::getHttpClient(
$username = '',
$password = '',
$service = 'youtube',
$client = null,
$source = 'My Videos', // a short string identifying your application
$loginToken = null,
$loginCaptcha = null,
$authenticationURL
);
$httpClient_ser = serialize($httpClient);
$sql = "INSERT INTO `you_tube_credentials` (`user_id`,`user_name`,`password`,`application`,`developer_key`,`http_client`)
VALUES
(1,'social@spotya.com','XXXXXXX','Spotya Videos','".$db->Escape($developerKey)."','".$db->Escape($httpClient_ser)."')";
$db->Query($sql);
header('location: youtube.php');
}
else
{
$httpClient = unserialize($auth['http_client']);
}
$sql = "SELECT * FROM `video_cue` WHERE `posted` < 4 AND `post_datetime` < '".date('Y-m-d H:i:m')."'";

$result = $db->Query($sql);
while($row = $db->FetchAssoc($result))
{
$transactionid = time();
Zend_Loader::loadClass('Zend_Gdata_YouTube');


$yt = new Zend_Gdata_YouTube($httpClient,"Spotya Videos",$clientID,$developerKey);

// create a new VideoEntry object
$myVideoEntry = new Zend_Gdata_YouTube_VideoEntry();

// create a new Zend_Gdata_App_MediaFileSource object
$filesource = $yt->newMediaFileSource(realpath('/pathtovideo/video_auto_upload/'.$row['file_name']));
//$filesource = $yt->newMediaFileSource(realpath('Wildlife.mp4'));

$filesource->setContentType('video/mp4');
// set slug header
$filesource->setSlug($row['file_name']);

// add the filesource to the video entry
$myVideoEntry->setMediaSource($filesource);

$myVideoEntry->setVideoTitle($row['title']);
$myVideoEntry->setVideoDescription($row['description']);
// The category must be a valid YouTube category!
$myVideoEntry->setVideoCategory('Education');

// Set keywords. Please note that this must be a comma-separated string
// and that individual keywords cannot contain whitespace
$myVideoEntry->SetVideoTags($row['tags']);


// upload URI for the currently authenticated user
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
// try to upload the video, catching a Zend_Gdata_App_HttpException,
// if available, or just a regular Zend_Gdata_App_Exception otherwise

$sql = "INSERT INTO `video_post_log` (`transactionid`,`sent`,`status`)
VALUES ('".$transactionid."',
'".$db->Escape(serialize($myVideoEntry))."',
'Initialized')";
$db->Query($sql);
try
{
$result = $yt->insertEntry($myVideoEntry, $uploadUrl, 'Zend_Gdata_YouTube_VideoEntry');
}
catch (Zend_Gdata_App_HttpException $httpException)
{
$result = $httpException->getRawResponseBody();
}
catch (Zend_Gdata_App_Exception $e)
{
$result = $e->getMessage();
}

if(is_array($result) == true || is_object($result) == true)
{
if(strpos($result,'xml') === false)
{
$result = serialize($result);
}
}
$sql = "UPDATE `video_post_log` SET `result`= '".$db->Escape($result)."',`status` = 'Complete' WHERE `transactionid` = '".$transactionid."'";
$db->Query($sql);
$sql = "UPDATE `video_cue` SET `posted`=`posted`+1 WHERE `file_name` = '".$row['file_name']."'";
$db->Query($sql);
}

最佳答案

我在堆栈跟踪中注意到了这一点:

Zend_Gdata_HttpClient->setAdapter(Object(__PHP_Incomplete_Class))

注意它是如何将 __PHP_Incomplete_Class对象传递给 setAdapter的。

我的猜测是,当您从数据库中提取对象并对其进行反序列化时,未加载要反序列化的类,这就是为什么它将成为 __PHP_Incomplete_Class对象的原因。

在尝试从数据库反序列化HTTP客户端之前,请尝试添加以下代码:
else
{
Zend_Loader_Autoloader::autoload('Zend_Gdata_HttpClient');
$httpClient = unserialize($auth['http_client']);
}

通过预加载该类,当您调用unserialize时,它应作为 Zend_Gdata_HttpClient而不是不完整的类出现。

如果这不起作用,请尝试同时加载 Zend_Http_Client,因为 Zend_Gdata_HttpClient就是从此扩展的。

编辑:也尝试使用更新的自动加载器;更换:
require_once('Zend/Loader.php');
Zend_Loader::loadClass('Zend_Gdata_HttpClient');

与:
require_once 'Zend/Loader/Autoloader.php';
$autoloader = Zend_Loader_Autoloader::getInstance(); // this sets up the ZF autoloader

Zend_Loader_Autoloader::autoload('Zend_Gdata_HttpClient');

关于api - 带有消息“传递的适配器不是HTTP连接适配器”的“Zend_Http_Client_Exception”,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11696106/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com