How to auto tweet via API in php using localhost? - php

I am new to PHP. I have the following code and i seriously would like to have the result posted as a tweet via its API. Can anybody provide an example code how would i be able to achieve that result? I think the twitter API script should go after the submit button or so. Also when i created twitter application for this, they asked me for a url but how can i provide it? Since i am using xampp server to run PHP scripts on port number 9999. So would entering localhost:9999 in the url work? Please and thanks...
<html>
<body>
<center>
<form action="abc.php" method="POST">
<textarea rows="5" cols="50" name="typehere"></textarea><br/>
<br/>
<input type="submit" class="button" value="tweet this">
<input type="reset" class="button" value="Clear">
</from>
<?php
error_reporting(0);
$tweet = $_POST["typehere"];
echo "The following tweet has been tweeted.";
echo $tweet;
?>
</div>
</center>
</body>
</html>

Try using the API "twitter-php"
This is the official website with a tutorial
https://code.google.com/p/twitter-php/
You need more than "text message" : the username and the password

Well using the Twitter API is a bit more complicated than that.
You can use Twitter's REST Api, who works like a charm. You'll need to authenticate the user before posting, and some other things.
The complete and easy documentation is there : https://dev.twitter.com/docs/api/1.1/post/statuses/update

Related

How to post HTML FORM Data to a http link given to you by a client using php

Hi guys im quite newbie on coding but i want to ask How to post HTML FORM Data to a http link given to you by a client thanks.
Try creating a .html file as below:
<html>
<form method="post" action="urclientlink">
<input type="text" name="firstname"/>
<input type="text" name="lastname"/>
<input type="text" name="submitButton" value="Submit Form"/>
</form>
</html>
Please elaborate on your question for a better answer. Thanks!
This is no different from submitting form data to a page on your own site. You simply amend the form's action attribute:
<form action="http://another-server.com/another-page">
You also need to be sure you get the right METHOD: e.g. GET or POST:
<form action="http://another-server.com/another-page" method="GET">
You will need to check with the client to see which page and method they need.

Trying a HTTP POST with Python

For a long time I love programming things that collects data for me. In Python I can make a GET request to a website and return the HTML of the website I would like to receive.
But in alot of websites you can POST something to the server and PHP would then respond/react on that sended data. How do I do this in Python?
For example, in the website at the bottom of this post I can insert my name and press the submit button to send the data to the PHP script. How do i do this in a socket with Python?
Also I really want to make it work without any libraries because ill be implementing it to other programs in other programming languages.
<html>
<body>
<form action="website.php" method="post">
<fieldset>
<br>
Enter your name:
<input type="text" name="un">
<center>
<input type=submit value=submit>
</center>
</fieldset>
</form>
</body>
</html>

php form handling based on w3school example not passing variables

I writing php from handling using this page as an example http://www.w3schools.com/php/php_forms.asp
To check if my form data is being passed to my php script, I am using echo statements. I have had no results, despite trying to print both my password and name. I have spent hours inspecting my code, and trying code from different examples, but nothing works.
I have read the stack overflow post form variables not passing to php, but I have confirmed that my php is working correctly, as I am able to print arrays from my database, as well as html paragraphs. Now I am prone to making really stupid mistakes, so it could be something like that, but I have been as thorough as possible.
Here is what I have done. (I have removed everything that is not relavent)
<form action="login.php" method="post">
<div id="name">
editors name: <input type="text" name="name">
</div>
<div id="pswd">
password: <input type="password" name="pwd">
</div>
<div id="submit">
<input type="submit">
</div>
</form>
login.php
<html>
<body>
<?php
echo $_POST["pwd"];
?>
</html>
</body>
Thank you very much to anyone who has any ideas. I really hope I did not forget something really stupid.
So it works now, I have no idea why it would not work before. Anyways that vardump was pretty usefull for at least letting me know what was going on in the background.

How to get the XML data from different server?

At present i am working on flight portal using PHP, SOAP , XML. We have taken the flight API from some 'X' provider. In that API they have given a sample file which contains international flight availability search Code. The code in that file is as below.
<HTML>
<HEAD>
<script language="Javascript">
function submit_search()
{
window.document.forms[0].action="http://URL/Avalability";
window.document.forms[0].submit();
}
</script>
</HEAD>
<BODY>
<form method="post">
XML Request: <input type="text" name="xmlRequest" id="fromcity" value="XML CODE FOR FLIGHT AVAILABILITY" />
<input type="button" name="SUBMIT" value="submit" onClick="submit_search();"/>
</form>
</BODY>
</HTML>
By executing the above code I am getting the Flight results in the other server . Now i want to get back that result into my file. How can we do that.
for your requirement you need to use ajax concept for getting the contents of those flight details from the server
this following url may helps you in this regard
http://www.java2s.com/Code/JavaScript/Development/functionloadstheXMLdocumentfromthespecifiedURL.htm
i hope it will provides a brief way to your solution
any comments are appreciated

Evernote Thumbnails

I am writing a simple application that lists all the Notes via the Evernote API. I have successfully authenticated and retrieved a list of Notes.
Now I am trying to get Note thumbnails via the Evernote API. I have read their [documentation here][1]. I tried a POST request, but for some reason it's not working. Obviously, I am doing something wrong. Can you please give me a quick, simple, example?
Example Code:
<form method="post" action="https://www.evernote.com/shard/s226/thm/note/64c08998-0bd3-4964-83fd-73a3baaf53cd.jpg?size=40">
<input type="submit" value="View Thumbnail">
</form>
I just set the form method to POST and action to Note Thumbnail. The note thumbnail works when you log in yourself into the Evernote website, but otherwise, it just says access denied. I am new to Evernote API, so I tried the above code just to see if that works or not.
Correct Example Code:
<form method="post" action="https://www.evernote.com/shard/s226/thm/note/64c08998-0bd3-4964-83fd-73a3baaf53cd.jpg?size=40">
<input type="hidden" name="auth" value="{authentication token}">
<input type="submit" value="View Thumbnail">
</form>
You will need to include the authentication token in the request.

Categories