Note that there are some explanatory texts on larger screens.

plurals
  1. PODifferent result from browser and from mobile
    text
    copied!<p>We have a wordpress web page, and we want to make a little app for iOs and android from this. So i've just made an API. The phone programmer is a freelancer, so at this time i have not her code, so this question will be devoted maybe, but maybe some of you will know the answer, if i tell, what i did.</p> <p>There are several methods in this API, but all of them (except login), need an authenticated user.</p> <p>So i made a request like this (now a working link): <a href="http://anydomain.com/service/app_request.php?request=login&amp;username=xxx&amp;password=yyy&amp;trid=zzz" rel="nofollow">http://anydomain.com/service/app_request.php?request=login&amp;username=xxx&amp;password=yyy&amp;trid=zzz</a></p> <p>This script start with a:</p> <pre><code>session_start(); include('../wp-load.php'); </code></pre> <p>So when she call the script with proper credentials, i do the login. </p> <pre><code> $creds = array(); $creds['user_login'] = $this-&gt;getVars['username']; $creds['user_password'] = $this-&gt;getVars['password']; $creds['remember'] = false; if (is_ssl()) { $secure_cookie = true; } else { $secure_cookie = false; } $user = wp_signon($creds, $secure_cookie); wp_set_current_user($user-&gt;ID); wp_set_auth_cookie($user-&gt;ID, false, false); $user-&gt;data-&gt;user_registered = $this-&gt;formatDateForApp($user-&gt;data-&gt;user_registered); $this-&gt;response['user'] = $user-&gt;data; </code></pre> <p>If i am using a browser from desktop, everything is fine, user is logged in, and i could call the requests.</p> <p>But when she try to use the logout request for example, script gives back, there was no user login:</p> <pre><code>require_once(ABSPATH . 'wp-includes/pluggable.php'); $user = wp_get_current_user(); if (empty($user) || empty($user-&gt;ID)) { $this-&gt;errorCode = NO_USER_WAS_LOGGED_IN; $this-&gt;errorMsg = 'No user was logged in'; } else { wp_logout(); $this-&gt;response['message'] = $user-&gt;data-&gt;user_login . " logged out"; } $this-&gt;showResponse(); </code></pre> <p>I am not familiar with mobile development, so i don't know, how is it handle the sessions. Could it be the problem? Or could it be a cookie problem?</p> <p>Another strange thing, if i call the search method (just get some post and give back the results in json), it works in browser, but when she tried to call it from the phone, she get back this for some reason:</p> <pre><code>&lt;html&gt; &lt;head&gt; &lt;meta http-equiv="refresh" content="0; url=http://59.xxx.xxx.xxx" /&gt; &lt;/head&gt; &lt;body&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>Yes, i know, it seems too generally, and without her code, it will be hard to figure out what causes the problem, but maybe some of you also has this issue, and can help us. I think a lot of people developed apps like this, what needs to login, and keep user logged in.</p> <p>Thank you.</p> <p><strong>UPDATE:</strong> This is a funny thing, and i've never meet before a problem like this. The developer is located in China. I checked that IP address through a browser, and guess what: that page is redirect her to this page:</p> <pre><code>http://59.151.88.32/index.php?source=unicomdns </code></pre> <p>what is actually the mobile provider, who is blocking her request for some reason. Solution could be a proxy, or i don't know, but now we know, it's not my service problem, and not her programs problem. This is a chines problem overall.</p>
 

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