|
|
 muneeba raja - 2015-02-09 11:42:10
Hi, I am trying to run the login_with_flickr.php from the terminal and it gives me this error message
PHP Notice: Undefined index: HTTP_HOST in srvv/home/rajam2/thesis/GetData.php on line 19
PHP Notice: Undefined index: REQUEST_URI in /srv/home/rajam2/thesis/GetData.php on line 20
What should I do to run it from the CLI?
Thanks
 Manuel Lemos - 2015-02-09 18:02:12 - In reply to message 1 from muneeba raja
You cannot run that script from the CLI like that because it requires running from a Web browser.
What you may try to do is to use PIN based authorization. You are redirected with the browser to a page that shows you a PIN code. Then from the CLI you can pass the PIN to the class to complete the authorization process. Take a look at this article:
phpclasses.org/blog/package/7700/po ...
 muneeba raja - 2015-02-14 10:40:48 - In reply to message 2 from Manuel Lemos
Hi thankyou for your message.
I tried using the pin method. I successfully get the pin by setting redirect_uri='oob'; . However when I hard code that pin in the script, keeping the redirect uri='oob', and run it from the terminal, then it doesnot successfully run the API's that require authorization. It fails giving errors like 'requst to non-object' and precisely this ->
"stat":"fail","code":98,"message":"Invalid auth token"
can you guide a little bit with this?
 Manuel Lemos - 2015-02-14 16:06:36 - In reply to message 3 from muneeba raja
You need to set the pin variable to whatever is the pin code. DId you do that?
 muneeba raja - 2015-02-14 20:55:21 - In reply to message 4 from Manuel Lemos
yes I am setting the $client->pin = $PIN_CODE;
where I copy the value of $PIN_CODE from the one I got on the webpage with "oob" authentication.
I tried entering the pin code both with and without hyphens in between the digits but I get the same error.
Thanks
 Manuel Lemos - 2015-02-15 01:29:40 - In reply to message 5 from muneeba raja
I tried it here it works correctly. The PIN must be passed as is including hyphens.
I even updated the enter_pin.php script to list Flickr as one the supported examples to work with PIN based authentication.
If you errors saying "request to non-object" it is because you have a mistake in your code. What code do you have in the line that issues the "request to non-object" error?
 muneeba raja - 2015-02-15 22:21:01 - In reply to message 6 from Manuel Lemos
If i run the same code from the web browser, then it runs successfully. The issue only comes from the cli. I am pasting here the php log file in the success case(from web browser) and failed case(from cli) for the same key that I get after redirect->uri=oob;
the difference lies on line no 3 'the Oauth token is not yet authorized' and 'OAuth client: The OAuth access token is not set'
--------------success case;-----------------------------
[Mon Feb 16 00:00:50.897294 2015] [:error] [pid 19858] [client ::1:51867] OAuth client: Checking the OAuth token authorization state
[Mon Feb 16 00:00:50.897423 2015] [:error] [pid 19858] [client ::1:51867] OAuth client: The OAuth token is not yet authorized
[Mon Feb 16 00:00:50.897445 2015] [:error] [pid 19858] [client ::1:51867] OAuth client: Checking the pin
[Mon Feb 16 00:00:50.897485 2015] [:error] [pid 19858] [client ::1:51867] OAuth client: Accessing the OAuth access token at http://www.flickr.com/services/oauth/access_token
[Mon Feb 16 00:00:50.897709 2015] [:error] [pid 19858] [client ::1:51867] Connecting to www.flickr.com
[Mon Feb 16 00:00:50.897745 2015] [:error] [pid 19858] [client ::1:51867] Resolving HTTP server domain "www.flickr.com"...
[Mon Feb 16 00:00:50.939475 2015] [:error] [pid 19858] [client ::1:51867] Connecting to HTTP server IP 66.196.66.213 port 80...
[Mon Feb 16 00:00:50.972784 2015] [:error] [pid 19858] [client ::1:51867] Connected to www.flickr.com
[Mon Feb 16 00:00:50.973032 2015] [:error] [pid 19858] [client ::1:51867] C GET
-------------failure case-------------
cf339b7d9f14f4da0ac240f8314896a512f6cddefeef3699OAuth client: Checking the OAuth token authorization state
PHP Warning: session_start(): Cannot send session cookie - headers already sent by (output started at /var/www/html/thesis/testing_cli.php:45) in /var/www/html/thesis/oauth_client.php on line 1244
PHP Warning: session_start(): Cannot send session cache limiter - headers already sent (output started at /var/www/html/thesis/testing_cli.php:45) in /var/www/html/thesis/oauth_client.php on line 1244
OAuth client: The OAuth access token is not set
OAuth client: Requesting the unauthorized OAuth token
OAuth client: Accessing the OAuth request token at http://www.flickr.com/services/oauth/request_token
Connecting to www.flickr.com
Resolving HTTP server domain "www.flickr.com"...
Connecting to HTTP server IP 66.196.66.212 port 80...
Connected to www.flickr.com
C GET
 Manuel Lemos - 2015-02-15 22:45:39 - In reply to message 7 from muneeba raja
Ah, to make it work in the cli, you need to use a sub-class of the oauth_client_class that stores tokens in a persistent container like for instance a database because the base class uses sessions for storage and sessions do not exist in the cli.
Here is a tutorial on how to store and retrieve token values from a MySQL database table.
phpclasses.org/blog/package/7700/po ...
 muneeba raja - 2015-02-16 08:52:40 - In reply to message 8 from Manuel Lemos
I see. I am doing some Flickr users crawl project and I am using the Flickr API method flickr.groups.members.getList, which basically requires authentication. This runs for a very long time and captures huge data. Do you think that running from the browser can successfully crawl through a big data without stopping or having some browser issues? Do you know any settings that I can make to keep the browser running for long time without going to idle state?
Or is the CLI only option?
Thanks,
 Manuel Lemos - 2015-02-16 09:44:49 - In reply to message 9 from muneeba raja
I think you may need to do it offline, so it can work when the user is not present, as users get added to the groups.
The class can work offline using some persistent storage like a database, instead of sessions, so there is no issue in making it work offline.
Anyway, the question is why do you need the pin based authorization?
You can obtain the tokens when the user is present and use them when the user is not present. You do not need pin based authorization for that. Just adapt the example in the article above to work with Flickr instead of Google.
|