Browse Source

Evolution #100: Ecrire des récupérations de vignette

bastien 13 years ago
parent
commit
8bd85a9a06
1 changed files with 34 additions and 0 deletions
  1. 34 0
      src/Muzich/CoreBundle/ElementFactory/Site/SoundcloudcomFactory.php

+ 34 - 0
src/Muzich/CoreBundle/ElementFactory/Site/SoundcloudcomFactory.php View File

@@ -57,6 +57,40 @@ class SoundcloudcomFactory extends BaseFactory
57 57
     
58 58
     return null;
59 59
   }
60
+  
61
+  public function getThumbnailUrl()
62
+  {
63
+    
64
+    
65
+    $url_object = $this->element->getUrl();
66
+    $url = null;
67
+    
68
+    $ch = curl_init('http://api.soundcloud.com/resolve.json?url='.$url_object.'&client_id=39946ea18e3d78d64c0ac95a025794e1');
69
+      
70
+    $options = array(
71
+      CURLOPT_RETURNTRANSFER => true,
72
+      CURLOPT_HTTPHEADER => array('Content-type: application/json')
73
+    );
74
+
75
+    curl_setopt_array( $ch, $options );
76
+    $result = json_decode(curl_exec($ch));
77
+    
78
+    if (isset($result->errors))
79
+    {
80
+      if (count($result->errors))
81
+      {
82
+        return null;
83
+      }
84
+    }
85
+    
86
+    $getjsonurl = $result->location;
87
+    $ch = curl_init($getjsonurl);
88
+    curl_setopt_array($ch, $options);
89
+    $result = json_decode(curl_exec($ch));
90
+    
91
+    $url = $result->artwork_url;
92
+    return $url;
93
+  }
60 94
 }
61 95
 
62 96
 ?>