Note that there are some explanatory texts on larger screens.

plurals
  1. POAndroid to Drupal cookie transfer Q2
    primarykey
    data
    text
    <p>Previously I asked a question at <a href="https://stackoverflow.com/questions/6208359/android-to-drupal-cookie-transfer">Android to Drupal cookie transfer</a> about sending cookies from my Android app back to my Drupal website to which I got a very good answer. The entire idea is to enable a persistent Client-Server interaction.</p> <p>I adjusted my code as was directed but I still can not get things working right. My code adjustments are below:</p> <pre><code>protected Void doInBackground(Void... params) { // TODO Auto-generated method stub HttpResponse response; HttpClient httpClient = new DefaultHttpClient(); HttpPost httpPost = new HttpPost("http://testsite.com/testpoint/node/"); BasicHttpContext basicContext = new BasicHttpContext(); org.apache.http.client.CookieStore cookiestore = new BasicCookieStore(); basicContext.setAttribute(ClientContext.COOKIE_STORE, cookiestore); basicContext.setAttribute(USERPREFERENCES.getString(COOKIE_NAME, ""), USERPREFERENCES.getString(COOKIE_VALUE, "") ); //USERPREFERENCES.getString(CO0OKIE_NAME, ""), USERPREFERENCES.getString(COOKIE_VALUE, "") // TODO Auto-generated method stub try{ List&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;(); nameValuePairs.add( new BasicNameValuePair("node[title]", "sample node from app") ); nameValuePairs.add( new BasicNameValuePair("node[type]", "story") ); nameValuePairs.add( new BasicNameValuePair("node[body]", "sample app node body content") ); httpPost.setEntity( new UrlEncodedFormEntity(nameValuePairs)); //Execute HTTP post request //HttpResponse response = httpClient.execute(httpPost, basicContext); Log.i("SEEMS TO WORK", response.toString()); Log.v("CODE", httpPost.getRequestLine().toString() + " - " + response.toString()); }catch(Exception e){ Log.e("HTTP-ERROR: node creation", e.toString()); } return null; } @Override protected void onPostExecute(Void result) { // TODO Auto-generated method stub super.onPostExecute(result); //Toast.makeText(getApplicationContext(), "Create Node thread returning!", Toast.LENGTH_LONG).show(); Toast.makeText(getApplicationContext(), "Testing header: Cookie: " + USERPREFERENCES.getString(COOKIE_NAME, "") +","+ USERPREFERENCES.getString(COOKIE_VALUE, ""), Toast.LENGTH_LONG).show(); } } </code></pre> <p>Basically, my cookie name and value are stored in my shared preferences USERPREFERENCES.getString(COOKIE_NAME, "") and USERPREFERENCES.getString(COOKIE_VALUE, ""). I am trying to send that information back so that when this function executes and successfully creates a new story node on my Drupal site, the author is recognized as the user who registered and signed in from the Android app.</p> <p>At present, the node is created but the user is "anonymous". Hence, I need to send back Drupal's user cookie information.</p> <p>Can anyone please assist me?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload