PHP - How To Auto Login And Post In Wordpress By Php Snoopy Or Curl ?
Currently I can use php snoopy class to auto login in wordpress, but when I try to use the same method to post some articles in wordpress. It does not work. Any one has any ideas?
I have tried to use httpwatch to monitor the post data and cookies. It seems I have include everything, but still doesn't work. thanks very much. This really driving me crazy. <?php include "Snoopy.class.php"; $snoopy = new Snoopy; //login part $submit_url = "http://localhost/wordpress/wp-login.php"; $submit_vars["log"] = "baibai"; //username $submit_vars["pwd"] = "123456"; //password $submit_vars["rememberme"] = "forever"; $submit_vars["redirect_to"] = "http://localhost/wordpress/wp-admin/"; $submit_vars["testcookie"] = "1"; $submit_vars["wp_sumbit"] = "submit"; $snoopy->submit($submit_url,$submit_vars); print $snoopy->results; $snoopy->setcookies(); $cookies = $snoopy->cookies; print_r ($cookies); //above part runs perfectly //post $snoopy->fetchform("http://localhost/wordpress/wp-admin/press-this.php"); print $snoopy->results; preg_match('/name=\"_wpnonce\" value=\"([0-9a-z]+)/',$snoopy->results,$matches); print $submit_vars1["_wpnonce"] = $matches[1]; $submit_vars1["autosave"] = ""; $submit_vars1["newtag[post_tag]"] = ""; $submit_vars1["tax_input[post_tag]"] = ""; $submit_vars1["autosave"] = ""; $submit_vars1["title"] = "title"; $submit_vars1["content"] = "content this is what i want post in wordpress"; $submit_vars1["original_post_status"] = "draft"; $submit_vars1["prev_status"] = "draft"; $submit_vars1["post_type"] = "text"; $submit_vars1["publish"] = "发布"; $submit_vars1["_wp_http_referer"] = "/wordpress/wp-admin/press-this.php?u=http%3A%2F%2Flocalhost%2Fwordpress%2Fwp-admin%2Ftools.php&t=%E5%B7%A5%E5%85%B7%20%E2%80%B9%20ekeyvision%20%E2%80%94%20WordPress&s=&v=4"; $submit_url1 = "http://localhost/wordpress/wp-admin/press-this.php?action=post"; $snoopy->submit($submit_url1,$submit_vars1); print $snoopy->results; ?> Also I do not want to use XML-RPC to solve this issue, since xml-rpc are not available is some settings. thanks Similar TutorialsHi guys, what I'm struggling to do is 1) Users land on https://www.mysite.com/login.php 2) Users type their email and password 3) POST data submitted to http://www.3rdparty.com/login.php with cURL 4) Users redirected to http://www.3rdparty.com/index.php (logged in). I've been using this simple form to POST directly to the 3rd party site. Code: [Select] <form name="loginform" method="post" target="_blank" action="http://www.3rdparty.com/login.php"> Email <input name="email" type="text"> Password<input name="password" type="password"> <input name="submit" type="submit" id="loginbutton" value="login"></form> This works great. But now I've installed a SSL on my site and I've just realised that using the form above, the data is still POSTed as a plain text because the 3rd party site is not https. So I want to submit the form to my login.php form and let this form take the users to the 3rd party site. So at least the user inputs to my site is encrypted. My new code looks like this. Code: [Select] <form name="loginform" method="post" target="_blank" action="login.php"> Email <input name="email" type="text"> Password<input name="password" type="password"> <input name="submit" type="submit" id="loginbutton" value="login"></form> <?php if(isset($_POST['email'])) $email= $_POST['email']; if(isset($_POST['password'])) $password= $_POST['password']; if(isset($_POST['submit'])) $submit = $_POST['submit']; $Curl_Session = curl_init('http://www.3rdparty.com/login.php'); curl_setopt ($Curl_Session, CURLOPT_POST, 1); curl_setopt ($Curl_Session, CURLOPT_POSTFIELDS, "email=$email&password=$password&submit=$submit"); curl_setopt ($Curl_Session, CURLOPT_FOLLOWLOCATION, 1); $result = curl_exec ($Curl_Session); curl_exec ($Curl_Session); curl_close ($Curl_Session); print $result; ?> What this code is doing now is it's just rendering the www.3rdparty.com's login page (not logged in) on my site. When I type wrong values, it renders www.3rdparty.com's login page with an error message on it. So I think at least the values are being POSTed but it doesn't log me in. All of the cURL codes available out there seem to POST the data and fetch some results back not redirecting the users to another site. My ultimate goal is to POST the form and redirect the users to the 3rd party site's member area as well. I tried header("Location: http://www.3rdparty.com/index.php"); but it just takes user to that page without being logged in. Could anyone give me some hints? $post='{"cart_items":[{"configuration":{"price":100,"recharge_number":"9999999999"},"product_id":"999","qty":1}]}';i try this n reslut was :There are no valid items in cart: help me plz Edited by ShivaGupta, 30 November 2014 - 01:11 AM. Hi,
I'm a novice and have the below code in a Wordpress theme. I'm trying to get the form to submit automatically so it logs an entry into the MySql db as though the person clicked the heart icon (submit). Ideally I subsequently want to hide the heart icon so on load maybe after 3 seconds the entry is auto fired to the MySql DB.
I have got as far as the manual click adding the entry, however can't get to to auto submit, any gel would be appreciated. Thank you in advance.
////PHP Form/////
<form class="ajax-form" action="<?php echo AJAX_URL; ?>" method="POST"> Hallo all, I am running a coupon website which will promote some website using coupons. I am using wordpress CMS. I would like to ask if somebody here could give me some enlightenment. I am using wordpress now and I would like everytime I post a coupon for a website like www example1. com it will automatically retrieve meta keywords value <meta name="keywords" content="perfume, fragrances, aftershave cosmetics, skin care, body, bath, beauty, products, moisturisers" /> examples. the script will automatic retrieve content from meta keywords and post it as a tag value on my posting. could anyone help me? thanks I am doing this: $fields = array( "code" => $this->code, "secret" => $this->secret, "domain" => $_SERVER['HTTP_HOST'], ); $this->ch = curl_init(); curl_setopt($this->ch, CURLOPT_URL, "http://weblyize.com/API/v1"); curl_setopt($this->ch, CURLOPT_FOLLOWLOCATION, true); curl_setopt($this->ch, CURLOPT_BINARYTRANSFER, true); curl_setopt($this->ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($this->ch, CURLOPT_POSTFIELDS, $fields); curl_setopt($this->ch, CURLOPT_POST, true); $opt = curl_exec($this->ch); return $opt; But the post fields are not being passed for some reason, and I can't figure out why. I do a print_r($_POST); on the url above, and it is empty. Do you see anything wrong with my curl? Here is the page: http://phpsnips.com/search/doSearch.php What setopt variables would i need to set with this request? Thanks I have a working API that I can get a json web token from in curl on my server, jquery ajax, postman, anything id like but php cURL.. I need help. I'm sure I'm over looking something easy. $curl = curl_init(); curl_setopt_array($curl, array( CURLOPT_URL => 'http://xxxxx/xxxxx/xxxx/auth/login', CURLOPT_RETURNTRANSFER => true, CURLOPT_ENCODING => '', CURLOPT_MAXREDIRS => 10, CURLOPT_TIMEOUT => 0, CURLOPT_FOLLOWLOCATION => true, CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1, CURLOPT_CUSTOMREQUEST => 'POST', CURLOPT_POSTFIELDS =>'{ "checked":"", "username":"xxxxxxxx", "password":"xxxxxxxx" }', CURLOPT_HTTPHEADER => array( 'Content-Type: application/json' ), )); $response = curl_exec($curl); curl_close($curl); echo $response;
Here is my Ajax code that works: <script> var settings = { "url": "xxxxxxx/xxxxxxx/xxxxxxxxx", "crossDomain": "true", "method": "POST", "timeout": 0, "headers": { "Content-Type": "application/json" }, "data": JSON.stringify({ "checked": "", "username": "xxxxxxxx", "password": "xxxxxxxx" }), };
$.ajax(settings).done(function (response) { console.log(response); });
</script>
Im lost. I have checked that cURL is enabled on my server. I have tested pulling webpages with cURL with out post data just fine. Edited March 24 by Thomas_Lremove url This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=333014.0 Hello, I have a website designed in simple php http://www.fsbizcollect.com/. It has a wordpress blog installed under sub-directory called "business-debt-collection-agency-blog" To query posts from blog on home page, I am using: <? foreach($sql->select("wp_posts", "where post_status = 'publish' order by post_date desc limit 3") as $row){ ?> <div class="bEntry"> <h2><?= $row['post_title'] ?></h2> <h3><?= date('F j, Y', strtotime($row['post_date'])) ?></h3> <p> <?= $row['post_excerpt'] ?> <a href="<?= $row['guid'] ?>">Read More</a></p> </div> <? } ?> It is working fine. I want to put post thumbnails on homepage. Post thumbnail should be automatically resized to width=110px and will be placed in : <div class="blogThumb"> POST THUMBNAIL PHP SCRIPT WILL COME HERE </div> Could anyone provide php script for this? Thank you I am setting up an API for my users, and the user sends post data via cURL. Is there a way I can see what site that the post data is coming from? would $_SERVER['REMOTE_HOST'] work? I am not using that to validate information. Users make entries into a form on my site which are then sent to a remote server which generates a variable length page of results for the users perusal. I want the results to be displayed on my site but I discover that iframe height is a problem so I am trying PHP in a separate file to avoid an iframe. Then maybe I can cache the result pages and display them without any height difficulties and not having to fiddle with javascript. The first PHP code I try is prevented from working and I discover that the apparent cause is the issue of fopen and fsockopen etc. being set to off by the host that I use because of security concerns: $url="http://remote_server.cgi"; foreach($_POST as $key => $value) {$url .="$key=" . urlencode($value) . "&";} $array = file($url);] The host has cURL so I try that but the form entries are not being accepted as they are with a direct post from the form: $URL="http://remote_server.cgi"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $URL); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $_POST); curl_exec ($ch); curl_close ($ch); In case useragent is a problem at the remote server, I added: curl_setopt($ch,CURLOPT_USERAGENT,'Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.13) Gecko/20080311 Firefox/2.0.0.13'); I know all entries are received by the separate file by using: print_r($_POST); But the remote server still says "Error in form found. You are not authorized etc. etc... " Apparently the post data is not being sent like the form sends it. Any suggestions? Ive tried everything and cannot get this POST to work, page comes up blank. The output of curlgetinfo() shows: Code: [Select] Array ( [url] => http://app.alliedinsurance.com/find_agent/calcpage4_1_popup.cfm?RequestTimeout=180 [content_type] => text/html; charset=UTF-8 [http_code] => 200 [header_size] => 329 [request_size] => 450 [filetime] => -1 [ssl_verify_result] => 0 [redirect_count] => 0 [total_time] => 0.172622 [namelookup_time] => 0.02064 [connect_time] => 0.092116 [pretransfer_time] => 0.092244 [size_upload] => 0 [size_download] => 509 [speed_download] => 2948 [speed_upload] => 0 [download_content_length] => 0 [upload_content_length] => 0 [starttransfer_time] => 0.172563 [redirect_time] => 0 ) The whole code Im using: Code: [Select] <h2>Please Enter Zip Code</h2> <p> <form method="POST" action="<?php echo $_SERVER['PHP_SELF'];?>"> <input type="text" size="10" maxlength="10" name="zipcode" tabindex="1" value="<?php echo $_POST['zipcode'];?>" /> <input type="submit" value="Search" name="submit" tabindex="2" /> </form> <br /> <?php if(isset($_POST['submit'])) { $zipcode = $_POST['zipcode']; $userAgent = 'Mozilla/5.0 (Windows NT 6.1; rv:7.0.1) Gecko/20100101 Firefox/7.0.1'; $mercurl = "http://app.alliedinsurance.com/find_agent/calcpage4_1_popup.cfm?RequestTimeout=180"; $postcom = "City=&State=AR&ZipCode=" . urlencode($zipcode) . "&Miles=" . urlencode('20') . "&SubmitThis=Submit"; $ch = curl_init(); curl_setopt($ch, CURLOPT_USERAGENT, $userAgent); curl_setopt($ch, CURLOPT_URL,$mercurl); curl_setopt($ch, CURLOPT_FAILONERROR, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0); curl_setopt($ch, CURLOPT_AUTOREFERER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER,true); curl_setopt($ch, CURLOPT_TIMEOUT, 100); curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_HEADER_OUT, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, true); curl_setopt($ch, CURLOPT_COOKIEJAR, 'cookies.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt'); curl_setopt($ch, CURLOP_REFERRER, "http://app.alliedinsurance.com/find_agent/find_an_agent_popup.cfm"); curl_setopt($ch,CURLOPT_POST, 1); curl_setopt($ch,CURLOPT_POSTFIELDS,$postcom); $html = curl_exec($ch); print_r(curl_getinfo($ch)); $html = @mb_convert_encoding($html, 'HTML-ENTITIES', 'utf-8'); curl_close( $ch ); echo $html; ?> Hi, I am very excited, making my first post in this very qualified, highly active forum. I try to log in using curl. I do not know so much about the problem, but the login-cookie should be written to the server disk somehow, I think. I have tried the following two snippets. (The original source of the snippets and the login credentials for the site I am trying to log in to are indicated in the quoted code.) <?php // http://www.zgpzw.com/bbs/pz/liangpic.asp // http://www.zgpzw.com/bbs/pz/showpic.asp?number=4852&code=fb67aa6082363a6d // tsttst, tsttstpwd /* cookiejar.php http://curl.haxx.se/libcurl/php/examples/cookiejar.html This script is an example of using curl in php to log into on one page and then get another page passing all cookies from the first page along with you. If this script was a bit more advanced it might trick the server into thinking its netscape and even pass a fake referer, yo look like it surfed from a local page. */ $ch = curl_init(); curl_setopt($ch, CURLOPT_COOKIEJAR, "/tmp/cookieFileName"); curl_setopt($ch, CURLOPT_URL,"http://www.zgpzw.com/bbs/pz/liangpic.asp"); curl_setopt($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, 'username=tsttst&password=tsttstpwd&CookieDate=2&userhidden=2'); ob_start(); // prevent any output curl_exec ($ch); // execute the curl command ob_end_clean(); // stop preventing output curl_close ($ch); unset($ch); $ch = curl_init(); curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); curl_setopt($ch, CURLOPT_COOKIEFILE, "/tmp/cookieFileName"); curl_setopt($ch, CURLOPT_URL,"http://www.zgpzw.com/bbs/pz/showpic.asp?number=4852&code=fb67aa6082363a6d"); $buf2 = curl_exec ($ch); curl_close ($ch); // echo "<PRE>".htmlentities($buf2); echo $buf2; ?> <?php // http://www.knowledgesutra.com/forums/topic/38162-automatic-login-using-curl/ // INIT CURL $ch = curl_init(); // SET URL FOR THE POST FORM LOGIN curl_setopt($ch, CURLOPT_URL, 'http://www.zgpzw.com/bbs/pz/liangpic.asp'); // ENABLE HTTP POST curl_setopt ($ch, CURLOPT_POST, 1); // SET POST PARAMETERS : FORM VALUES FOR EACH FIELD curl_setopt ($ch, CURLOPT_POSTFIELDS, 'username=tsttst&password=tsttstpwd&CookieDate=2&userhidden=2'); // IMITATE CLASSIC BROWSER'S BEHAVIOUR : HANDLE COOKIES curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); # Setting CURLOPT_RETURNTRANSFER variable to 1 will force cURL # not to print out the results of its query. # Instead, it will return the results as a string return value # from curl_exec() instead of the usual true/false. curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); // EXECUTE 1st REQUEST (FORM LOGIN) $store = curl_exec ($ch); // SET FILE TO DOWNLOAD curl_setopt($ch, CURLOPT_URL, 'http://www.zgpzw.com/bbs/pz/showpic.asp?number=4852&code=fb67aa6082363a6d'); // EXECUTE 2nd REQUEST (FILE DOWNLOAD) $content = curl_exec ($ch); // CLOSE CURL curl_close ($ch); echo $content; ?> I am trying to help a friend who is a collector of Chinese ration tickets. The login page I am trying to log in to is this: http://www.zgpzw.com/bbs/pz/liangpic.asp The log in form looks like this Code: [Select] <form method="post" action="../login.asp?action=chk" onSubmit="return checkLogin(this);"> <tr> <td width="60" height="27">???:</td> <td><input type="text" name="username" id="username" tabindex="1" style="width:120px;height:22px;BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: #666666 1px solid"/></td> </tr> <tr> <td width="60" height="27">??:</td> <td><input type="password" name="password" id="pwd1" tabindex="2" style="width:120px;height:22px;BORDER-RIGHT: #666666 1px solid; BORDER-TOP: #666666 1px solid; FONT-SIZE: 9pt; BORDER-LEFT: #666666 1px solid; BORDER-BOTTOM: #666666 1px solid"/></td> </tr> <tr> <td> </td> <td height="30"><input type="hidden" name="comeurl" value="/bbs/pz/showpic.asp?number=4852&code=fb67aa6082363a6d"/> <input name="CookieDate" type="hidden" value="2"> <input name="userhidden" type="hidden" value="2"> <input type=image alt=?? src="image/login.gif" name=image3 width="60" height="19"></td> </tr> </form> To check if my login is successful I try to curl down the following page: http://www.zgpzw.com/bbs/pz/showpic.asp?number=44213&code=f278c2ae7f53ba02 The proof that one would be correctly logged in is that the page would show pictures of Chinese ration tickets. (Not just text) If I go to the login page and provide the login data manually (putting logincookie not on server, but on my workstation) works, of course. http://www.zgpzw.com/bbs/pz/liangpic.asp The site is in Chinese, but I do not think it makes so much difference. If my question is unclear, please ask for clarifications. The two login scripts I am trying are not successful. (Or rather - I have failed in applying them.) What should I do to log in to this site using php-curl? Thanks. ycc
My real job is as a radio announcer. We are required to play advertising commercials for various programs that we broadcast. I wrote a script a few years ago to automatically login to the providers website (PHP, Curl) and download the mp3's that we are supposed to play each day. $url = 'http://domain.com/formprocessing.html'; $fields = array( 'username' => urlencode('xxx'), 'password' => urlencode('xxx') ); $fields_string = ''; foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string, '&'); //open connection $ch = curl_init(); //set the url, number of POST vars, POST data curl_setopt($ch,CURLOPT_URL, $url); curl_setopt($ch,CURLOPT_POST, count($fields)); curl_setopt($ch,CURLOPT_POSTFIELDS, $fields_string); //execute post $result = curl_exec($ch); //close connection curl_close($ch);
Hello I've been trying to login to a website using cURL, and display it's contents from the members area. This is the code I have so far: <?php $cookie="cookie.txt"; $postdata = "lkgqfwwxzvln=username&lickrxkXVSQecjgUJguaIXtgohvojodeUVRQrnDLXUEGQEn=password"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, "https://account.perfectworld.com/login"); curl_setopt ($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt ($ch, CURLOPT_USERAGENT, "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.1.6) Gecko/20070725 Firefox/2.0.0.6"); curl_setopt ($ch, CURLOPT_TIMEOUT, 60); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_COOKIEJAR, $cookie); curl_setopt ($ch, CURLOPT_REFERER, "http://core.perfectworld.com/home/"); curl_setopt ($ch, CURLOPT_POSTFIELDS, $postdata); curl_setopt ($ch, CURLOPT_POST, 1); $result = curl_exec ($ch); curl_close($ch); echo $result; exit; ?> I tried it at a wordpress login, and it worked very well. However, it doesn't seem to work with perfectworld.com, since the page returned says "Our sincerest apologies, we cannot provide service to players in your region or to players using open proxies.". Seems like they are detecting it somehow. Any way to bypass this? What I'm intending to do is parse out my character's level etc. which is available when logged in. thanks A 3rd party hosts our online ordering site that is integrated with our inventory software program. I have a customer login page on our "Corporate Site" and I am wanting to login to our "online ordering site" directly from this page. First I tried: Code: [Select] <p class="main_body"><form action="http://mysite.com/login javascript:window.location=http://my3rdparysite.com/login" method="post" id="contactform"><table><tr><td><input name="username" type="hidden" value="demo" /></td></tr><tr><td><input name="password" type="hidden" value="demo" /></td></tr><tr><td> </td><td><input name="Submit" type="submit" value="Sign in to Demo account" /></td></tr></table></form></p> This takes me to http://my3rdpartysite.com/login. The text on the page displays {"success":true,"route":"\/myname\/customer\/"} . So when I change the url in the browser from http://my3rdpartysite.com/login to http://my3rdpartysite.com/customer, I am logged in. So, then I researched to see if there is a way to inject javascript in the form or url so when it reaches 3rdpartysite.com/login, it would automatically redirect to 3rdpartysite.com/customer, then I would be logged in. _____________ Here is the other idea. Log into 3rdpartysite.com/login from customer login page on corporate site using curl, grab the sessionid, then redirect to the 3rdpartysite.com/customer?SESSIONID=$session....... except.. I do not know how to store the SESSIONID into $session. Code: [Select] <?PHP $headers = array("User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.8.0.8) Gecko/20061025 Firefox/1.5.0.8"); $url="http://my3rdpartysite.com/login"; $ch = curl_init(); curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookies.txt'); curl_setopt($ch, CURLOPT_COOKIEFILE, 'cookies.txt'); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, "username=demo&password=demo"); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_VERBOSE, 1); curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); curl_setopt($ch, CURLOPT_MAXREDIRS, 4); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); $store = curl_exec ($ch); curl_close ($ch); print_r($store); ?> <script type="text/javascript"> <!-- window.location = "http://my3rdpartysite.com/customer?SESSIONID=<?PHP echo"$SESSION";?>" //--> </script> Any ideas? Hi guys, I hope this is the right place to post this. I have two subdomains, one has authentication login already setup, so I just want to use the "single sign on" method using curl to achieve this. below is my script. I have tested it and it does pass variables to the authentication page but I can not be logged in, I am hoping you guys can help. $passed_vars='l_username='.$_REQUEST["l_username"].'&l_password='.$_REQUEST["l_password"].'&returnURL='.$_REQUEST["returnURL"]; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://example.com/play/login'); curl_setopt ($ch, CURLOPT_POST, 1); curl_setopt ($ch, CURLOPT_POSTFIELDS, $passed_vars); curl_setopt ($ch, CURLOPT_COOKIEJAR, 'cookie.txt'); curl_setopt ($ch,CURLOPT_COOKIEFILE, 'cookie.txt'); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); $store = curl_exec ($ch); curl_close($ch); when I do print_r($store) I can see the login page returned but no sessions set. Thanks This topic has been moved to PHP Applications. http://www.phpfreaks.com/forums/index.php?topic=348171.0 Hi, im looking to pull 3 posts from a specific Wordpress Category. At the minute I can pull 3 latest posts and display them in a flash banner using the code below. Code: [Select] SELECT yah_posts.*, yah_postmeta.* FROM yah_posts LEFT JOIN yah_postmeta ON yah_posts.ID = yah_postmeta.post_id WHERE yah_postmeta.meta_key = 'largeimage' && yah_posts.post_status = 'publish' ORDER BY post_date DESC LIMIT 3 I want to be able to pull 3 latest posts from a specific category instead of just 3 latest posts from every category. I have put together this code below, but it doesn't seem to be working Code: [Select] $query = "SELECT yah_posts.*, yah_postmeta.* FROM yah_posts LEFT JOIN yah_postmeta ON yah_posts.ID = yah_postmeta.post_id AND LEFT JOIN $yah_term_taxonomy ON($yah_term_relationships.term_taxonomy_id = $yah_term_taxonomy.term_taxonomy_id) WHERE yah_postmeta.meta_key = 'largeimage' && yah_posts.post_status = 'publish' AND $yah_term_taxonomy.term_id = '1' AND $yah_term_taxonomy.taxonomy = 'category' ORDER BY post_date DESC LIMIT 3"; I'm trying to send a HTTPS POST request with XML data to a server using PHP. Anything sends to the server requires authentication therefore I'll use cURL. Some background info.: the XML data is to request the server to upload a file from a specific URL to its local storage. One rule of using this API is I MUST set the content type for each request to application/xml. This is what I've done but isn't working... <?php $fields = array( 'data'=>'<n1:asset xmlns:n1="http://.....com/"><title>AAAA</title><fileName>http://192.168.11.30:8080/xxx.html</fileName><description>AAAA_desc</description><fileType>HTML</fileType></n1:asset>' ); $fields_string = ""; foreach($fields as $key=>$value) { $fields_string .= $key.'='.$value.'&'; } rtrim($fields_string,'&'); $url = "https://192.168.11.41:8443/"; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_POST, count($fields)); curl_setopt($ch, CURLOPT_POSTFIELDS, $fields_string); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false); curl_setopt($ch, CURLOPT_HEADER, true); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_USERPWD, "admin:12345678"); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-type: application/xml', 'Content-length: '. strlen($fields_string)) ); $result = curl_exec( $ch ); curl_close($ch); echo $result; ?> I am expected to get an XML reply of either upload successful or upload failed. But instead I am getting this error message. HTTP/1.1 415 Unsupported Media Type Server: Apache-Coyote/1.1 Content-Type: text/xml;charset=UTF-8 Content-Length: 0 Date: Thu, 02 Dec 2010 03:02:33 GMT I'm sure the file type is correct, the XML format is correct. I've tried urlencode the fields but it didn't work. What else I might have done wrong? |