-
שלום.
נתקלתי בבעיה בהעלאת והורדת קבצים להמרה ב API של zamzar.
משום מה רק שמות קבצים ותיקיות באנגלית מומרים כמו שצריך.
אני חייב דווקא שמות של קבצים ותקיות בעברית.יש פתרון לבעיה הזו?
תודה רבה....
-
@odeddvir
מה הכוונה?
לזה? https://developers.zamzar.com/user -
@odeddvir
ב PHP.$endpoint = "https://sandbox.zamzar.com/v1/jobs"; $apiKey = "****"; $sourceFilePath = "C:\wamp64\www\A/שבת.mp3"; $targetFormat = "mp4"; $sourceFile = "mp3"; // Since PHP 5.5+ CURLFile is the preferred method for uploading files if(function_exists('curl_file_create')) { $sourceFile = curl_file_create($sourceFilePath); } else { $sourceFile = '@' . realpath($sourceFilePath); } $postData = array( "source_file" => $sourceFile, "target_format" => $targetFormat ); $ch = curl_init(); // Init curl curl_setopt($ch, CURLOPT_URL, $endpoint); // API endpoint curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); //curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false); // Enable the @ prefix for uploading files curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return response as a string curl_setopt($ch, CURLOPT_USERPWD, $apiKey . ":"); // Set the API key as the basic auth username $body = curl_exec($ch); curl_close($ch); $response = json_decode($body, true); echo "Response:\n---------\n"; //print_r($response); -
@odeddvir
ב PHP.$endpoint = "https://sandbox.zamzar.com/v1/jobs"; $apiKey = "****"; $sourceFilePath = "C:\wamp64\www\A/שבת.mp3"; $targetFormat = "mp4"; $sourceFile = "mp3"; // Since PHP 5.5+ CURLFile is the preferred method for uploading files if(function_exists('curl_file_create')) { $sourceFile = curl_file_create($sourceFilePath); } else { $sourceFile = '@' . realpath($sourceFilePath); } $postData = array( "source_file" => $sourceFile, "target_format" => $targetFormat ); $ch = curl_init(); // Init curl curl_setopt($ch, CURLOPT_URL, $endpoint); // API endpoint curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); //curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false); // Enable the @ prefix for uploading files curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return response as a string curl_setopt($ch, CURLOPT_USERPWD, $apiKey . ":"); // Set the API key as the basic auth username $body = curl_exec($ch); curl_close($ch); $response = json_decode($body, true); echo "Response:\n---------\n"; //print_r($response); -
@ass נסה להחליף את שורה 15 ב:
"source_file" => @iconv("UTF-8","Windows-1252//IGNORE",$sourceFile); -
@odeddvir
לא עובד, גם אם כל הנתיב באנגלית.
כלומר, שכתוב ככה לא עובד"source_file" => @iconv("UTF-8","Windows-1252//IGNORE",$sourceFile),אבל ככה עובד רק אנגלית:
"source_file" =>$sourceFile, -
אם זה רק בשביל ההמרה, לא צריך API, אפשר עם ffmpeg
https://stackoverflow.com/questions/25381086/convert-mp3-video-with-static-image-ffmpeg-libav-bash -
@odeddvir
שלום.
למרות שעבר זמן, חזרתי לקוד שלי שוב.
הבנתי שהוא פשוט לא מצליח לקרוא את שם הקובץ בעברית.
כלומר() iconvלא עוזר בגלל שצריך 3 פרמטרים שהם מחרוזת, אבל בגלל שהפרמטר האחרון זה הקובץ והוא לא מצליח לקבל את הקובץ, אז מבחינתו זה NULL ולא מחרוזת, ולכן מתקבלת השגיאה:iconv() expects parameter 3 to be string, object givenכך ראיתי פה.
השאלה אם יש עוד סיבה שהוא לא מצליח לקרוא.
-
@odeddvir
שלום.
למרות שעבר זמן, חזרתי לקוד שלי שוב.
הבנתי שהוא פשוט לא מצליח לקרוא את שם הקובץ בעברית.
כלומר() iconvלא עוזר בגלל שצריך 3 פרמטרים שהם מחרוזת, אבל בגלל שהפרמטר האחרון זה הקובץ והוא לא מצליח לקבל את הקובץ, אז מבחינתו זה NULL ולא מחרוזת, ולכן מתקבלת השגיאה:iconv() expects parameter 3 to be string, object givenכך ראיתי פה.
השאלה אם יש עוד סיבה שהוא לא מצליח לקרוא.
-
@odeddvir
גיליתי שמשום מה על שרת אחר שלי זה כן עובד.
השרת שלא עובד רץ עם Wampserver
והשרת שכן עובד רץ עם: nginx ו php שמותקן ידנית.זה קשור?
@ass האם הPHP הוא אותו גרסה בשניהם?
נ.ב. אחד ווינדוס ואחד לינוקס לא? -
@ass האם הPHP הוא אותו גרסה בשניהם?
נ.ב. אחד ווינדוס ואחד לינוקס לא?@a0533057932
שניהם ווינדוס. (אחד VPS ואחד מקומי על המחשב האישי שלי)
הגרסאות שניהם מעל 5.5
זה הקוד המלא://המרה להעלאה $endpoint = "https://sandbox.zamzar.com/v1/jobs"; $apiKey = "*****"; $n = "א"; $sourceFilePath = "C:/$n.mp3"; $targetFormat = "mp4"; // Since PHP 5.5+ CURLFile is the preferred method for uploading files if(function_exists('curl_file_create')) { $sourceFile = curl_file_create($sourceFilePath); } else { $sourceFile = '@' . realpath($sourceFilePath); } $postData = array( "source_file" => $sourceFile, "target_format" => $targetFormat ); $ch = curl_init(); // Init curl curl_setopt($ch, CURLOPT_URL, $endpoint); // API endpoint curl_setopt($ch, CURLOPT_CUSTOMREQUEST, 'POST'); curl_setopt($ch, CURLOPT_POSTFIELDS, $postData); //curl_setopt($ch, CURLOPT_SAFE_UPLOAD, false); // Enable the @ prefix for uploading files curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); // Return response as a string curl_setopt($ch, CURLOPT_USERPWD, $apiKey . ":"); // Set the API key as the basic auth username $body = curl_exec($ch); curl_close($ch); $nesponse = json_decode($body, true); echo "Response:\n---------\n"; print_r($nesponse);אני מחפש דרך להבין באיזה חלק זה שונה ממש שיש לי בשרת?
בתמיכה של החברה הציעו להדפיס באגים משיחת ה CURL.
לא כ"כ הבנתי מפה איך עושים את זה:
שלום! נראה שהשיחה הזו מעניינת אותך, אבל עדיין אין לך חשבון.
נמאס לכם לגלול בין אותם הפוסטים בכל ביקור? כשנרשמים לחשבון, תמיד תחזרו בדיוק למקום שבו הייתם קודם, ותוכלו לבחור לקבל התראות על תגובות חדשות (בין אם במייל, ובין אם בהתראת פוש). תוכלו גם לשמור סימניות ולפרגן ב-upvote לפוסטים כדי להביע הערכה לחברי קהילה אחרים.
בעזרת התרומה שלך, הפוסט הזה יכול להיות אפילו טוב יותר 💗
הרשמה התחברות
