nó đây! chả hiểu gì luôn -_-
PHP
property Client_ID : "XXXXXXX" property Client_Secret : "XXXXXXX" property refresh_token : "XXXXXXX" -- Supported file types property fileTypes : {"jpeg", "jpg", "gif", "png", "apng", "tiff", "bmp", "pdf", "xcf"} -- If true, this will enclose the URL in a [img][/img] tag property img_tag : true property listOfLinks : {} on run -- Verify the selected file is a supported file type tell application "Finder" set userSelect to (selection as alias list) if (count of userSelect) < 1 then tell me to badChoice() else if name extension of first item of userSelect is not in fileTypes then tell me to badChoice() end if end tell --Request new token set a to do shell script "curl -X POST -F client_id=" & Client_ID & " -F client_secret=" & Client_Secret & " -F grant_type=refresh_token -F refresh_token=" & refresh_token & " https://api.imgur.com/oauth2/token" set {TID, text item delimiters} to {text item delimiters, {"\"access_token\":\"", "\",\"expires_in"}} set new_token to text item 2 of a set text item delimiters to TID -- Upload the file repeat with i from 1 to number of items of the userSelect set selectedItem to item i of the userSelect set theFile to quoted form of POSIX path of selectedItem set imgurUpload to do shell script "curl -X POST -H 'Authorization: Bearer " & new_token & "' -F image=@" & theFile & " https://api.imgur.com/3/upload " -- Copy the URL into your clipboard set {TID, text item delimiters} to {text item delimiters, {"http:\\/\\/i.imgur.com\\/", "\"},\"success\":true,\"status\":200}"}} if img_tag then copy "[img]http://i.imgur.com/" & text item 2 of imgurUpload & "[/img]" & "\n" to the end of listOfLinks else copy "http://i.imgur.com/" & text item 2 of imgurUpload & "\n" to the end of listOfLinks end if -- Reset delimiters set text item delimiters to TID end repeat set the clipboard to listOfLinks as string set listOfLinks to {} end run on badChoice() using terms from application "Finder" tell me activate display alert "Please select ONE supported file and try again." message "Allowed file types: JPEG, JPG, GIF, PNG, APNG, TIFF, BMP, PDF, XCF (GIMP). " & return & return & "Please note that the TIFF, BMP, PDF and XCF formats will be converted to PNG on upload." buttons "OK" cancel button "OK" end tell end using terms from end badChoice
![[OFF]](/assets/images/off.gif)