Comments (20)
So is there a fucking solution after 6 years??
from zendgdata.
God. Last time I ever use this incomplete shitty framework.
from zendgdata.
I have the same problem: http://framework.zend.com/issues/browse/ZF2-559
from zendgdata.
I can verify this as well, there's no setRawData() method in \Zend\HttpClient or the parent class \Zend\Http\Client
from zendgdata.
Can you try to replace setRawDataStream method in HttpClient.php with the following code and check if it works?
public function setRawDataStream($data, $enctype = null)
{
$this->_streamingRequest = true;
if($enctype) $this->setEncType($enctype);
return $this->setRawBody($data);
}
from zendgdata.
@rcknr Using this to upload a file this gives a new error:
strlen() expects parameter 1 to be string, object given (2) at line 1082 in /vendor/zendframework/zendframework/library/Zend/Http/Client.php
from zendgdata.
@gullij Then try this:
public function setRawDataStream($data, $enctype = null)
{
$this->_streamingRequest = true;
if($enctype) $this->setEncType($enctype);
return $this->setRawBody($data->_fileHandle);
}
from zendgdata.
That gives this:
PHP Fatal error: Cannot access protected property ZendGData\MediaMimeStream::$_fileHandle in /vendor/zendframework/zendgdata/library/ZendGData/HttpClient.php on line 347
There's no getter for $_fileHandle in MediaMimeStream so I tested adding that but that creates this error:
PHP Fatal error: Call to a member function read() on a non-object in /vendor/zendframework/zendgdata/library/ZendGData/HttpAdapterStreamingSocket.php on line 83
from zendgdata.
@gullij It would be great if you show me your code :) It seems like zf2 can handle stream uploads itself if you give it a file handle instead of MediaMimeStream object as a body of the request.
ZF2 documentation is obsolete and still suggests setRawData for such cases.
from zendgdata.
I was just about to suggest I give you my code, it's really just the ZF1 example code updated towards ZF2 so if the documentation is obsolete I might be doing something wrong in this
<?php
/**
* Direct uploading of movies to YouTube
*/
$youTubeAPIKey = "API_KEY";
$authenticationURL= 'https://www.google.com/accounts/ClientLogin';
$uploadUrl = 'http://uploads.gdata.youtube.com/feeds/api/users/default/uploads';
$username = 'USERNAME';
$password = 'KEYWORD';
$file = 'FULL_FILE_PATH';
require 'vendor/autoload.php';
try {
// TODO: Fix to avoid "sslcapath" exception - something that should be fixed in later version.
// The client is created only to set the sslcapath option, it isn't necessary to create the client in most cases.
$client = new \ZendGData\HttpClient();
$client->setAdapter('Zend\Http\Client\Adapter\Socket');
$client->getAdapter()->setOptions(array('sslverifypeer' => false));
$httpClient = \ZendGData\ClientLogin::getHttpClient(
$username,
$password,
$service = 'youtube',
$client,
$source = 'UploaderTest', // a short string identifying your application
$loginToken = null,
$loginCaptcha = null,
$authenticationURL);
$yt = new \ZendGData\YouTube($httpClient, "DirectUpload-0.0.1", "App-Key", $youTubeAPIKey);
$videoEntry = new \ZendGData\YouTube\VideoEntry();
// Add file
$finfo = new finfo(FILEINFO_MIME_TYPE);
$mimeType = $finfo->file($file);
$filesource = $yt->newMediaFileSource($file);
$filesource->setContentType($mimeType);
$filesource->setSlug(basename($file));
$videoEntry->setMediaSource($filesource);
$videoEntry->setVideoTitle("Test movie");
$videoEntry->setVideoDescription("This is a test movie");
// Make the entry unlisted - only users with the exact path can see it.
$unlisted = new \ZendGData\App\Extension\Element('yt:accessControl', 'yt', 'http://gdata.youtube.com/schemas/2007', '');
$unlisted->setExtensionAttributes(array(
array('namespaceUri' => '', 'name' => 'action', 'value' => 'list'),
array('namespaceUri' => '', 'name' => 'permission', 'value' => 'denied')
));
$videoEntry->setExtensionElements(array($unlisted));
$videoEntry->setVideoCategory('Autos');
$videoEntry->setVideoTags('cars, funny');
// Upload the entry
$newEntry = $yt->insertEntry($videoEntry, $uploadUrl, '\ZendGData\YouTube\VideoEntry');
$editUrl = $newEntry->getEditLink()->getHref();
print "Uploaded: ".$newEntry->getId()." - ".$newEntry->getVideoId()."\n";
} catch (Exception $e) {
print $e->getMessage()."\n";
print $e->getTraceAsString()."\n";
}
function out($string)
{
print $string."\n";
}
from zendgdata.
Is there anyone looking into this or has it died off?
from zendgdata.
Hi, I'm also looking for a solution to this, thanks.
from zendgdata.
Agree.
from zendgdata.
This seems to be partly fixed, now the returned error is the same as this:
zendframework/zendframework#2645
from zendgdata.
Agree. You can work with the bare API without using Zend though.
from zendgdata.
Cool! Don't see Youtube among supported APIs though.
Here you go: https://code.google.com/p/google-api-php-client/source/browse/trunk/src/contrib/Google_YoutubeService.php
from zendgdata.
@gullij Have you solved the problem?
Thanks,
from zendgdata.
Sorry, I had forgotten about this.
No, I haven't solved the problem but then again I haven't tested with the latest versions of ZF2 but because the ZendGData component is no longer maintained it's probably not worth spending time on this. Using Google's own is probably the best way to solve this although they have a history of changing their APIs quite often, breaking backwards compatibility.
Their API is here:
https://developers.google.com/youtube/2.0/developers_guide_php
This uses Zend_GData_YouTube from ZF1 so I guess there are a few years until there's a proper PHP 5.3+ version of this.
from zendgdata.
Should probably use this client library:
https://developers.google.com/youtube/v3/libraries
from zendgdata.
Any solutions yet? Google's client library seems incomplete. Can you even do direct uploads with it?
from zendgdata.
Related Issues (12)
- Empty field stop ListQuery and first field is never printed
- Zend_Gdata_App_MediaFileSource uses fread() in a wrong way
- How to catch Zend_Gdata_App_AuthException HOT 1
- Fatal error: Call to a member function resetParameters() on a non-object
- Can't add ZendGData into vendor/Zend HOT 1
- Expected response code 200, got 403
- ZEND GDATA Google spread sheet data feeding issue HOT 1
- How to use this using google oauth2.0?
- Unable to enable crypto on TCP connection HOT 11
- Class access error in ZendGData\App at line 230
- YouTube requests doesn't send developer_key HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from zendgdata.