I know there is a ready to use API for facebook, but since I last tried the API they change to much, now you need permissions an checks for everything you want to do ...
This project is only for personal usage, therefore I don't care about give my facebook password.
My goal is to make an comment to an picture on a facebook page, in this test aviciis
I created my first git repo https://github.com/fritz-net/facebook-AntiAPI because i have 4 files. For login etc. I hope this messy testing code is readable
The problem is that facebook shows an error that something happened (no acces, wrong page, out of date,... - German stuff),... even though the http headers are the same and the post data too. There is no point why facebook should not save this comment like any other. The login also worked well.
I'm using the mobile version because with the ajax/json version i had no real success either.
I hope I forget nothing about my problem in my tiredness. I tried to find other code from people who had done this, but everyone uses the api and I also tried to solve the problem myself for the last 6 hours (from about 02am till now 8) please excuse my bad English writing, dirty code and missing things
Maybe someone can give me a hint, good night
It turned out that solution was very easy.
in the api.class.php there is a regex where I read out the form action, I added the following $action = str_replace("&", "&", $action); and everything worked.
The problem where the html entities in the action url of the form
EDIT: I committed the changes to github for anyone interested
Related
I have a script to browse through tumblr blogs without looking at all the blogs individually. I use the old, simple tumblr-api. It worked perfect until tumblr now shows one of these new privacy messages first, that one has to click to continue.
I guess, after the click tumblr sets a cookie, but I can't find a way to get this cookie working for my php script...
if you put in the browser:
http://nakedworldofmars.tumblr.com/api/read/json?start=0&num=5&type=photo
usually you get a json with lot's of data that then can be used. But now this privacy warning comes first. After you once clicked "ok" the api-call works in the browser, actually after the "ok" you are directly redirected and he json-code is delivered. With the next call the warning page does not appear anymore (unless you delete cookies).
Now I use this in a php-script:
<?php
$testread = file_get_contents('http://nakedworldofmars.tumblr.com/api/read/json?start=0&num=5&type=photo');
if (strpos($testread, 'Before you continue') !== false) {
echo $testread;
}
?>
I thought, clicking the "ok" on the echoed page would produce the cookie.
But it doesn't work.
Anybody has any idea how I can make that tumblr knows that my php-script has seen and accepted the page?
I faced exactly the same problem since yesterday – I am using javascript, though. After several trials to solve this using the old API I failed and thus finally just switched to the new API (v2). I also hesitated to do so at first because I am not too familiar with dealing with OAuth keys as well. But it turned out to be quite easy – and it worked instantly. I used this guide as a starting point:
http://www.developerdrive.com/2014/05/how-to-get-started-with-the-tumblr-api-part-1/
http://www.developerdrive.com/2014/05/how-to-get-started-with-the-tumblr-api-part-2/
This isn't a real code problem but more a where and how to start problem.
So I hope you can give me some creative ideas, examples or share your thoughts !
After login in to a website, I can change my product details, this is done by HTTP POST forms.
Because we have over 1000 products I somehow want to customise / easyify.
My idea was, make a PHP form on my own server which submits to the supplier url(s).
However when doing this, it forwards us to the customer login.
If I temper my submitted data in firefox, I see this is because after login a cookie is been set and obvious our system does not have this.
Anyone an idea how to automate this process ? In other words, how can I set this cookie in my php form in order to submit it succesfully.
Or Im I thinking about the wrong solution ?!
You cannot post to another server unless you use cURL or something like that. Maybe I am not understanding your question.
I have ran into a serious problem that must be resolved before continuing with the development.
My boss created the app, for him it works exactly as expected - the user is logged in, the data is accessible, everything works. BUT for every other user, $facebook->getUser() ALWAYS returns 0, no matter what. Obviously, I'm logged into facebook, there is also a login link in the app, but clicking it doesn't work, nothing changes.
This problem only occurs for users that are not in any way connected to the app!
I confirmed my developer request to that app a few days ago and it now works for my account, before that it did not work, not for me, not for any other user we tried, no matter if the app was public or in dev mode, which technically shouldn't matter for authentication.
We tried many things, eventually existing code shared on the internet, like the code from the bottom of this article: http://www.thegeekstuff.com/2014/03/develop-facebook-app/
(with our own app ID and secret, of course)
Not that it changed anything, but just to give you a ready code example.
Even if I deleted everything below "$user = $facebook->getUser();" and just put echo $user; die(); after that, it always showed the user ID as 0.
Another thing I've noticed that might help in solving this problem is the following: with the same code from the article, my boss' session contains several variables at all times, but when I open the app with a non-dev user, at first there is only the "fb_app-id_state" variable, and when I refresh the page, it gets deleted and session is empty. If I refresh the page again, the variable is created again with a different value, another refresh and it's gone again, and so on.
After a day of trying to get this shit to work with PHP, I switched to the JS SDK. Apparently it also doesn't work, however, I have yet to receive specifics from my boss since I don't have a fake account to test it myself.
The obvious question is: what is going on and why isn't the authentication working as expected?
Edit: my code - http://pastebin.com/qCPtfTHs
You need looking for app settings. Only owner, app admin, dev, can use your aplication on sandbox mode. All other users this app dont work or work buggy. Remove test mode, and put out app in live mode.
I've been working on a website which contains alot of links. I want to protect those links from bots/crawlers by implementing a CAPTCHA. I've tried reCAPTCHA by Google but it doesn't suit my needs(complex specially when it comes to people who are poor in English :P) plus I just want to stop the new programmers or crawlers, I know it can easily be broken by experienced programmers. So I searched and found this one to be good.
http://www.hardcode.nl/subcategory_4/article_243-simple-php-captcha-script.htm
Downloaded it and its working like a charm but my problem is :
1. I can see the index.html files checks the entered code and if correct redirects to write.php where session is created and output is shown. I want this to be done on the same page. Like when user enters correct code, he should be able to view the view the links on the same page to save bandwidth (I'll fetch them from mysql server)
2. This is more important one, since I don't know anything about php sessions and php.net tutorials are just too short or next to nothing, can this be done that whenever a user input correct captcha once, he can see the links for rest of the time without captcha? And he will have to re-enter the captcha only when he closes the browser or after some interval like 10 minutes in case previous one can't be done.
Thank you
PS. I can use Javascript on my server but probably a php solution will be better since I'm also learning php
Use AJAX to pull the links and then replace the HTML in the page.
Store a variable in the session that determines whether or not they've entered a CAPTCHA, then just check that before deciding whether to show the CAPTCHA or the links.
I am using
Back
to provide a back to previous page link. It works fine on Windows (IE/Mozilla) but fails in Safari on both Windows/Mac.
Is there a way to make it work on all of the systems/browsers (cross-browser/platform)?
If it's not possible, is there any other way using PHP etc?
it should be history.go(-1); return false;
or
history.go(-1); event.preventDefault();
You should consider doing it like this instead:
Back
Try this instead. It should work across IE, FF, Safari and Chrome.
<a href="#" onclick="if(document.referrer) {window.open(document.referrer,'_self');} else {history.go(-1);} return false;">Cancel<a>
The below code is working.
Back
If anyone is still struggling with this issue try removing the href-attribute from the link you want to use window.history.back() with. I'm not sure if this workaround complies with HTML-standards but it worked out fine for me.
I've faced the same issue recently, and although I'm not exactly sure why, this is the solution that worked for me:
If the user is on iOS:
history.go(-2)
If not:
history.go(-1)
I faced a similar issue on an e-commerce site I have been building for one of my customers. I initially went the route of calling:
window.history.back();
when the button was clicked. I encountered the same problem you are having with cross compatibility issues.
To answer you question about
If it's not possible, is there any other way using PHP etc?
My opinion is you should not invoke a method on the server to do a client operation. This is unnecessary overhead on your app and in my opinion, poor design/implementation.
Now to answer your main question:
Is there a way to make it work on all of the systems/browsers (cross-browser/platform)?
To solve the issue I found a client cookie library produced by Mozilla (https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie) from another StackOverflow post (my apologies to the author - I don't have the link to your post).
Using the library I create a cookie with a key of 'back-url' when the user navigates to the part of my app where I want them to be able to go back:
$('#id-of-button-clicked').click(function() {
docCookies.setItem("back-url", window.location.href, ".myDomain.com", "/");
});
This code sets a cookie with a key-value pair 'back-url', and the current url and makes it accessible from the root directory of myDomain.com.
Next, on the page where I want the user to be able to navigate back to the URL set in the cookie, I call the following code:
$(‘#id-of-back-button’).click(function() {
window.location.href = docCookies.getItem('back-url');
});
This code sets the window location by getting the value of 'back-url'.
Disclaimer: I am no professional js developer - just trying to put in my two cents from some lessons I have learned.
Challenges to this answer:
This answer uses cookies, many people don't like the use of cookies. My customers requirements allow me to use cookies.
I'm not encrypting the cookie - some may consider this bad practice. I am still in the early implementation phase of our development. I am, however, restricting access to the cookie to only within our domain.