ID: 45540
User updated by: jdespatis at yahoo dot fr
Reported By: jdespatis at yahoo dot fr
Status: Open
Bug Type: Streams related
Operating System: Linux Kubuntu
PHP Version: 5.2.6
New Comment:
And to help to diagnose the problem
i can perfectly make this script work if I code the stream by my own
for example, I replace stream_context_create by some code using
fsockopen, all works perfectly ... (i really think stream_context_create
leaves some \r \n in some special case ...)
$context = stream_context_create($opts);
$buff =
@file_get_contents(http://uploads.gdata.youtube.com/feeds/api/users/$username/uploads;,
false, $context);
by
$fp = fsockopen(uploads.gdata.youtube.com, 80, $errno, $errstr, 30);
if (!$fp) {
return Youtube unreachable $errstr ($errno);
}
$out = POST /feeds/api/users/$username/uploads HTTP/1.0\r\n;
$out .= Host: uploads.gdata.youtube.com\r\n;
$out .= Content-Length: . strlen($opts[http][content] .\r\n;
$out .= Connection: Close\r\n;
$out .= $opts[http][header];
$out .= \r\n;
$out .= $opts[http][content];
fwrite($fp, $out);
$buff = ;
while (!feof($fp)) {
$buff .= fgets($fp, 4096);
}
fclose($fp);
Previous Comments:
[2008-07-18 08:44:26] jdespatis at yahoo dot fr
No this bug is different than bug 43222.
In the latter the post content seems to be good except a CRLF more
which is not dramatic
In my case, the post content and header are completely broken...
I've modified my configuration to forbid short open tag
(i check with echo ini_get(short_open_tag) which returns nothing
meaning false)
and i get the same bug.
But as I said, one could thing the bug comes from here (i've thought
also), but not at all, the bug disappear if i let the short tag ? but
change something else
Php behavior is really weird...
[2008-07-17 22:46:57] [EMAIL PROTECTED]
Are you sure this isn't same issue as reported in bug #43222 ?
What was the configure line you used to configure PHP?
Is short_open_tag enabled? Check from phpinfo()!
[2008-07-17 07:14:41] jdespatis at yahoo dot fr
Oups, my script bug.php contains a function
To test it, one can use this simple script :
(no need to create a nothing.mp4 to use this example)
?php
include(bug.php);
$params = array(username = bigbluezen, password = demo,
title = ultimate video topmoumoute, tags = test machin bidule,
channel = poetic);
print_r(publish(nothing.mp4, $params));
?
[2008-07-17 07:10:23] jdespatis at yahoo dot fr
Description:
I'm coding a little script to upload a video on Youtube, thanks to
stream functions in php.
It takes 2 steps:
1/ first connect on google to retrieve token, no problem with php code
2/ upload video with a query in POST, and there stream_context_create
is giving a completely broken query.. From time to time, i can make it
work, but it's pure random
I have used a sniffer as wireshark to see the exact http query
Reproduce code:
---
Here is the piece of code that does all this stuff:
http://www.despatis.com/php/bug.phps
Expected result:
PHP CLIENT = YOUTUBE SERVER:
POST /feeds/api/users/bigbluezen/uploads HTTP/1.0
Host: uploads.gdata.youtube.com
Content-Length: 792
Content-Type: multipart/related;
boundary=---cefe168b3cb99683a0f9ebd6f9b2cca6
Authorization: GoogleLogin
auth=AIwbFAQtr5MDW_ctllHioiYCpY6I_uF6A9zBcSbIQ8AceGbcYfqrmytEICM8p6VjjzygDd2HPL0YhTcVk2MPmtb9y93-9Fs3yiej8hBtLF60_N_a6aWDg9Mrbm18nP-2dTVvTA6h77eJZrOJICzgN3dZyPT4AN1ffQ
X-GData-Client: ytapi-SourceRH-LaCartoonerie-3lludu8g-0
X-GData-Key:
key=AI39si44WZavBNwYryVhVFaMH4Y8e0JbTAr83bScAxKby6LBW3xEyBzaXrV7MTw3sm56SmYVhSOWRXNfUrS0sqC1i7313ycFrQ
Slug: c447e7c1c0b79e8dc97c76cdc16e9843.gif
-cefe168b3cb99683a0f9ebd6f9b2cca6
Content-Type: application/atom+xml; charset=UTF-8
?xml version=1.0?
entry xmlns=http://www.w3.org/2005/Atom;
xmlns:media=http://search.yahoo.com/mrss/;
xmlns:yt=http://gdata.youtube.com/schemas/2007;
media:group
media:title type=plaintitle foo/media:title
media:description type=plaindescription
foo/media:description
media:category
scheme=http://gdata.youtube.com/schemas/2007/categories.cat;People/media:category
media:keywordskey1, key2/media:keywords
/media:group
/entry
-cefe168b3cb99683a0f9ebd6f9b2cca6
Content-Type: video/gif
Content-Transfer-Encoding: binary
XXX
-cefe168b3cb99683a0f9ebd6f9b2cca6--
Actual result:
--
The actual result, found with a sniffer (wireshark for example) is:
PHP CLIENT = YOUTUBE SERVER:
POST
/feeds/api/users/bigbluezen/uploads/wFqcFtuB9MY?client=ytapi-SourceRH-LaCartoonerie-3lludu8g-0