Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $imageurl = "http://resimadres.jpg";
- $PostTitle = "Yazı Başlığı";
- $PostContent = "Yazı içeriği"
- $PostTags = Array("Etiket 1,Etiket 2");
- $PostCategoryID = 1; // Category ID
- // IMAGE Upload
- $myFile = 'temp/' . rand(0,90000) . '-image.jpg';
- $content = file_get_contents($imageurl);
- if(!file_exists($myFile)){touch($myFile);}
- file_put_contents($myFile, $content);
- $fh = fopen($myFile, 'r');
- $fs = filesize($myFile);
- $theData = fread($fh, $fs);
- fclose($fh);
- $client->debug = false;
- $params = array('name' => $myFile , 'type' => 'image/jpg', 'bits' => new IXR_Base64($theData), 'overwrite' => true);
- $res = $client->query('wp.uploadFile',1, $username, $password, $params);
- $clientResponse = $client->getResponse();
- if(isset($clientResponse['faultCode'])){ die("İmaj dosyası yüklenemedi. Lütfen kontrol ediniz."); }
- unlink($myFile);
- $thumbnail = $clientResponse['thumbnail'];
- $original_url = $clientResponse['url'];
- $thumbnail_id = $clientResponse['id'];
- // IMAGE Upload
- $params = xmlrpc_encode_request('wp.newPost', array(0,$username,$password, array('post_title' => $PostTitle,'post_content' => $PostContent,'post_status' => 'publish','post_thumbnail' => $thumbnail_id, 'comment_status' => 'open', 'terms_names' => array('post_tag' => $PostTags,'category' => "1" )) ),array('encoding'=>'UTF-8','escaping'=>'markup'));
- $ch = curl_init();
- curl_setopt($ch, CURLOPT_URL, $url);
- curl_setopt($ch, CURLOPT_POST, TRUE);
- curl_setopt($ch, CURLOPT_POSTFIELDS, $params);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
- curl_setopt($ch, CURLOPT_TIMEOUT, 1);
- $veri= curl_exec($ch);
- curl_close($ch);
- echo "
- " . $veri . ' : ID Eklendi!
- ';
Add Comment
Please, Sign In to add comment