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']);
$response = $connection->post('favorites/create/'.$fav);
The ID is not a parameter.
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
If I'm not mistaken, you don't need to add an "id" parameter.
Looking at Twitter's Documentation 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.
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);
精彩评论