Could someone create a little script for me please :)

Status
Not open for further replies.

pisoj1

Active Member
141
2010
0
0
I'm not the best coder, I know php and html fairly well but no where near like a real coder.

I've created a form which creates a post for me, i'd like if I put a URL of a img in one of the input fields it will upload it to lulzimg...this probably takes some smart people 2-3min to do. Would anyone be able to assist me with it? I read that I need to use curl. I've never experienced any of that :(

I went into phpuploader and tried to take its script to see if I can make it work for me...I could not >_<

Code:
	$postfields['image'] = "http://ia.media-imdb.com/images/M/MV5BMTkzNzY5OTc3Nl5BMl5BanBnXkFtZTcwNjE4NDQzMQ@@._V1._SX214_CR0,0,214,314_.jpg";
	$postfields['submit'] = "submit";
	$page = curl("http://lulzimg.com/app.php", $postfields, "");
	preg_match('#http(.*)#', $page, $match);
	$imglink = trim($match[0]);
	echo $imglink;

That's what I tried it would not work. Any ideas on how to help me please. I would put a vraible for $postfields instead of the URL but this was for testing purposes.

i'm a complete nub so I really have no idea
 
10 comments
Maybe you can find something usefull from this:
PHP:
<?php

// set url of image
$img&nbsp;&nbsp; &nbsp;= 'http://www.google.com/intl/en_ALL/images/srpr/logo1w.png';

// open url of API
$url&nbsp;&nbsp; &nbsp;= 'http://freedirectlink.com/tools/imageshack_api.php?img=' . $img;

// declare cURL
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$site = curl_exec($ch);
curl_close($ch);

// decode output from API
$out&nbsp;&nbsp; &nbsp;= json_decode($site);

// echo result image only
echo $out->image;

?>
http://buzzknow.com/2010/08/02/remote-upload-to-imageshack-with-php-curl/

http://blog.smileylover.com/remote-upload-to-imageshackus-with-phpcurl/


EDIT: gunda316, im faster :P
 
Here's the code (with a function) :) :

PHP:
function postHost($url, $data, $cookie, $credentials){
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $url);
    if($cookie != "")
        curl_setopt($ch, CURLOPT_COOKIE, $cookie);
    if($data != ""){
        curl_setopt($ch, CURLOPT_POST, 1);
        curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
    }
    if($credentials != ""){
        curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
        curl_setopt($ch, CURLOPT_USERPWD, $credentials);

    }
    //curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
    curl_setopt($ch, CURLOPT_HEADER, 1);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER,1);
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('Expect:')); 
    $page = curl_exec($ch);
    curl_close($ch);
    return $page;
        
}
$img =  postHost("http://www.lulzimg.com/upload.php?submit=lulz&url=$url", "", "", "");
preg_match_all("/http:\/\/lulzimg.com\/[a-z0-9]+\/[a-z0-9A-Z.\-\[\]]+/", $img, $matches);
$link = $matches[0][1];
echo "Your link sir: $link";

EDIT: l0calh0st, i'm precise ^_^
 
sorry i'm quite a noob i'm trying to use gunda's but I can't figure out what variable is ment to be the URL of the image I want uploaded. Can anyone help with that?
 
thanks guys really helped me out a lot...now if someone is willing to share a IMDB scrapper/grabber script....:P do it :)
 
Status
Not open for further replies.
Back
Top