标签: imgur

Imgur API上传

所以有这行代码

String data = URLEncoder.encode("image", "UTF-8") + "=" + URLEncoder.encode(Base64.encodeBase64String(baos.toByteArray()).toString(), "UTF-8");

data += "&" + URLEncoder.encode("key", "UTF-8") + "=" + URLEncoder.encode(YOUR API KEY GOES HERE, "UTF-8");
Run Code Online (Sandbox Code Playgroud)

当我注册Imgur API时,我得到了一个client_id和一个client_secret,并想知道我在哪里使用哪个"你的API密钥就在这里"也在第二行的第一部分,它说"关键"是什么我进入那里?也是上传它的网站http://imgur.com/api/upload因为我看过几个不同的网站.

java api imgur

2
推荐指数
1
解决办法
7219
查看次数

cURL请求从imgur api获得NULL响应

    $image = file_get_contents($_FILES['upload']['tmp_name']);
    $id = 'myid';
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, 'https://api.imgur.com/3/image.json');
    curl_setopt($ch, CURLOPT_POST, TRUE);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array( 'Authorization: Client-ID ' . $id));
    curl_setopt($ch, CURLOPT_POSTFIELDS, array( 'image' => base64_encode($image) ));
    $response = curl_exec($ch);
    curl_close($ch);
    $response = json_decode($response);
Run Code Online (Sandbox Code Playgroud)

这是我必须将匿名图片上传到imgur的引用块.它适用于我的mac os机器上的xampp,但它不能在我的Windows上使用xampp.我也知道关于windows xampp卷曲的以下内容:

-it is enabled
-it works when i try to grab the content of an url
-it doesnt work when i try to make DELETE request to remove an anonymous image(the same code works on the mac os …
Run Code Online (Sandbox Code Playgroud)

php api xampp curl imgur

2
推荐指数
1
解决办法
3054
查看次数

使用Dropzone.JS将图像上传到Imgur

我已经创建了一个页面,网站的用户可以通过拖放来上传图片.为此,我使用Dropzone.JS (转到infositeGithub),我将文件上传到Imgur.

问题是我不知道如何用DropZone.JS做到这一点.这是我用于实现Dropzone-class的代码.

<div class="dropzone">
    <div class="fallback">
        <input name="file" type="file" multiple />
    </div>
</div>

<script src="~/Scripts/DropZone.js" type="text/javascript"></script>    

<script>
    var myDropzone = new Dropzone(".dropzone", { 
        url: "https://api.imgur.com/3/image", 
        Authorization: 'Client-ID MY_CLIENT_ID'
    });
</script>
Run Code Online (Sandbox Code Playgroud)

以下是我从Imgur得到的回复

{
    "data": {
        "error": "An image ID is required for a GET request to /image",
        "request": "/3/image",
        "method": "GET"
    },
    "success": false,
    "status": 400
}
Run Code Online (Sandbox Code Playgroud)

出现此错误:

XMLHttpRequest无法加载https://api.imgur.com/3/image.预检响应中Cache-Control不允许请求标头字段Access-Control-Allow-Headers.

如果请求成功,我也会从Imgur获取上传图像的URL.

javascript imgur dropzone.js

2
推荐指数
1
解决办法
1384
查看次数

使用python直接通过url从imgur下载文件

有时,文件扩展名不提供指向imgur的链接.例如:http://imgur.com/rqCqA.我想下载文件并给它一个已知名称或在更大的代码中获取它的名字.问题是我不知道文件类型,所以我不知道给它的扩展名.

我怎么能在python或bash中实现这一点?

python bash imgur

1
推荐指数
1
解决办法
3112
查看次数

WebView无法加载Imgur相册

这是一个奇怪的问题,但我不确定该从这里尝试什么.在我的应用程序中,用户可以打开各种链接,我已经为其提供了一个带有WebView的Fragment.这些链接中很大一部分是Imgur专辑,但由于某些原因,我的设备或我尝试过的模拟器上的专辑无法正确加载专辑.我已经设置了一个带有单个WebView的应用程序,它显示了这里的行为:https://github.com/damien5314/imgur-album-webview.

我在Chrome中设置了WebView调试,并在WebView中并排加载了页面,并在启用了移动模拟的桌面Chrome上加载了该页面.在桌面Chrome上,页面在从api.imgur.com收到带有图像列表的响应后加载,然后在页面加载后下载并显示各个图像.在我的设备上的WebView上,在收到Imgur API的响应后,永远不会下载图像.

注意 - 只有Imgur 相册页面给我提问.单个图像加载得很好.

mWebView.loadUrl("http://imgur.com/a/2dtj8"); // Album, does not load images
// mWebView.loadUrl("https://imgur.com/X2eInSx"); // Single image, works fine
Run Code Online (Sandbox Code Playgroud)

我想说这是他在Android上的JS的Imgur问题,但由于JS被混淆了我的网页调试选项是有限的,更不用说我可以在类似的应用程序中加载WebView中的相同链接,所以必须有一些使它工作的方式.如果有人在我的代码中看到任何问题让我知道,否则任何有关调试此问题的后续步骤的建议将不胜感激.谢谢!

javascript android webview imgur

1
推荐指数
1
解决办法
697
查看次数

System.UnauthorizedAccessException:拒绝访问路径(UWP C#)

我正在开发一个uwp平台,该平台允许使用imgur api将图像上传到imgur。我正在这样做:

var picker = new Windows.Storage.Pickers.FileOpenPicker();
        picker.ViewMode = Windows.Storage.Pickers.PickerViewMode.Thumbnail;
        picker.SuggestedStartLocation =
            Windows.Storage.Pickers.PickerLocationId.PicturesLibrary;
        picker.FileTypeFilter.Add(".jpg");
        picker.FileTypeFilter.Add(".jpeg");
        picker.FileTypeFilter.Add(".png");
        String path;

        Windows.Storage.StorageFile file = await picker.PickSingleFileAsync();
        if (file != null)
        {
            path = file.Path;
        }
        else
        {
            path = "Operation cancelled.";
        }
try
            {
                var client = new ImgurClient("id", "secret");
                var endpoint = new ImageEndpoint(client);
                IImage img;
            await Task.Run(async () =>
            {
                await Task.Yield();
                Debug.Write("crash at FileStream\n");
                using (var fs = new FileStream(@path, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    Debug.Write("crash at Upload\n");
                    img = await …
Run Code Online (Sandbox Code Playgroud)

.net c# imgur access-rights uwp

1
推荐指数
1
解决办法
2632
查看次数

Imgur通过客户端javascript上传,但不是node.js. 狼狈

这有效:

    $.post( 
        'http://api.imgur.com/2/upload.json', 
        { 
            key: 'dsfdwerwersf53534dfsfse3', 
            image: 'http://i.imgur.com/UH17u.png' 
        }, 
        function( data ) { console.log( data.upload.links.original ); }
    );
Run Code Online (Sandbox Code Playgroud)

当我在Chrome的控制台中运行时,imgur会立即向我发送上传图片的网址:http://i.imgur.com/KrHMY.png.优秀.

.

现在我在服务器端使用node.js尝试同样的事情,但它不起作用:

    var 
        express = require( 'express' )
    ,   app = express.createServer()
    ,   request = require( 'superagent' );


    app.get( '/', function( req, res ) {
        request
            .post( 'http://api.imgur.com/2/upload.json' )
            .send( { key: 'dsfdwerwersf53534dfsfse3', image: 'http://i.imgur.com/UH17u.png' } )
            .end( function( data ) {
                console.log( data.upload.links.original );
            });
    });

    app.listen( '8080' );
Run Code Online (Sandbox Code Playgroud)

当我运行node.js应用程序时,imgur会发回这个响应:

text: '{"error":{"message":"No API key was sent, and no …
Run Code Online (Sandbox Code Playgroud)

javascript jquery node.js imgur

0
推荐指数
1
解决办法
971
查看次数

标签 统计

imgur ×7

javascript ×3

api ×2

.net ×1

access-rights ×1

android ×1

bash ×1

c# ×1

curl ×1

dropzone.js ×1

java ×1

jquery ×1

node.js ×1

php ×1

python ×1

uwp ×1

webview ×1

xampp ×1