Ankündigung

Einklappen
Keine Ankündigung bisher.

Fotos zu Flickr über die API hochladen

Einklappen

Neue Werbung 2019

Einklappen
X
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Fotos zu Flickr über die API hochladen

    Hallo,
    wie der Titel schon sagt lade ich Bilder über die API zu Flickr hoch.
    Das klappt soweit auch, nur brauche ich die richtige Bildurl anschließend.
    Das will einfach nicht klappen!

    Jemand eine Idee wie das auf meinen Code anzuwenden wäre?


    PHP-Code:
    <?php
        
    require_once("phpFlickr.php");
        
    $error=0;
        
    $f null;
        if(
    $_POST){
            if(!
    $_POST['name'] || !$_FILES["file"]["name"]){
                
    $error=1;
            }else{
                if (
    $_FILES["file"]["error"] > 0){
                    echo 
    "Error: " $_FILES["file"]["error"] . "<br />";
                }else if(
    $_FILES["file"]["type"] != "image/jpg" && $_FILES["file"]["type"] != "image/jpeg" && $_FILES["file"]["type"] != "image/png" && $_FILES["file"]["type"] != "image/gif"){
                    
    $error 3;
                }else if(
    intval($_FILES["file"]["size"]) > 525000){
                    
    $error 4;
                }else{
                    
    $dirdirname($_FILES["file"]["tmp_name"]);
                    
    $newpath=$dir."/".$_FILES["file"]["name"];
                    
    rename($_FILES["file"]["tmp_name"],$newpath);
                    
    $status uploadPhoto($newpath$_POST["name"]);
                    if(!
    $status) {
                        
    $error 2;
                    }
                }
            }
        }
        function 
    uploadPhoto($path$title) {
            
    $apiKey "geheim";
            
    $apiSecret "strenggeheim";
            
    $permissions "write";
            
    $token "nochvielgeheimer";
            
    $f = new phpFlickr($apiKey$apiSecrettrue);
            
    $f->setToken($token);
            
    print_r($f);
            return 
    $f->async_upload($path$title);
        }
    ?>

    <form action="txt2html.php" method="post" accept-charset="utf-8" enctype='multipart/form-data'>
    <input type="file" name="file"/><br />
    <input type="submit" value="Submit" /><br />
    </form>

  • #2
    Das mit dem gezeigten Code irgendwas funktioniert möchte ich nicht so recht glauben, so wie PHP und HTML vermischt ist. Wo sind die PHP Tags?

    Kommentar


    • #3
      ja ich hab die Tags jetzt einfach nicht mitkopiert, da hab nur das wichtigste zusammen geschnitten. Aber das war ja auch nicht die Frage, außerdem steht in meinem Post dass das Script funktioniert!
      Aber der vollständigkeitshalber mach ich es nur für dich rein

      Kommentar


      • #4
        Vorleseservice aus der phpFlickr Doku
        The basic difference is that synchronous uploading waits around until Flickr processes the photo and returns a PhotoID. Asynchronous just uploads the picture and gets a "ticketid" that you can use to check on the status of your upload. Asynchronous is much faster, though the photoid won't be instantly available for you.

        Kommentar


        • #5
          Danke für den hochnäsigen Hinweis das ich wohl zu doof zum lesen bin.
          Von aSync auf Sync hab ich nun umgestellt und ich erhalte eine ID als return.
          Und nun? Wie kann ich von der ID auf die tatsächliche URL des Bildes schließen?

          Kommentar


          • #6
            http://www.flickr.com/photos/{user-id}/{photo-id} - individual photo

            url:
            http://www.flickr.com/services/api/misc.urls.html

            Kommentar

            Lädt...
            X