What's wrong with this PHP Twitter API POST?

PHP Post not working with twitter api

  • Im trying to use the following PHP to add a favorite to my account: <?php if(isset($_POST['submit'])) { $fav = $_REQUEST['fav']; $connection->post('favorites/create', array('id' => $fav)); echo "<div style='padding-bottom: 5px; color: #0099FF;'>Fav Created Successfully.</div>"; } ?> With the following form: <form id="fav" method='post' action='index.php'> <input type="text" style="width: 346px;" name="fav" id="fav" ></input> <input type="submit" value="Fav This!" name="submit" id="submit" /> </form> Its not creating a favorite, Can anyone spot anything wrong with it? PS: I am using the OAuth API: $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']);

  • Answer:

    If I'm not mistaken, you don't need to add an "id" parameter. Looking at http://dev.twitter.com/doc/post/favorites/create/%3aid the URL to create a favorite would be http://api.twitter.com/1/favorites/create/12345.xml where "12345" is the ID of the tweet.

CLiown at Stack Overflow Visit the source

Was this solution helpful to you?

Other answers

$response = $connection->post('favorites/create/'.$fav); The ID is not a parameter.

CLiown

When I tried it, it says the following. This method requires a GET. Although Twitter API documentation says it requires a POST. So, try to do a GET request on it: $response = $connection->get('favorites/create', array('id' => $fav)); // now print the response to see if any error pops up: print_r($response);

shamittomar

Im trying to use the following PHP to add a favorite to my account: $favorite = $connection->post('favorites/create/'.$id); where $id is the status id but favorite don't return nothing

alexandra

Related Q & A:

Just Added Q & A:

Find solution

For every problem there is a solution! Proved by Solucija.

  • Got an issue and looking for advice?

  • Ask Solucija to search every corner of the Web for help.

  • Get workable solutions and helpful tips in a moment.

Just ask Solucija about an issue you face and immediately get a list of ready solutions, answers and tips from other Internet users. We always provide the most suitable and complete answer to your question at the top, along with a few good alternatives below.