php
  • twitter
  • oauth
  • 2010-09-05 29 views 2 likes 
    2

    進出口工作嘗試使用下面的PHP的最愛我的帳戶:PHP後不與Twitter的API

    <?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>"; 
    
        } 
    ?> 
    

    通過以下形式:

    <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> 
    

    它不是建立一個喜歡的,任何人都可以發現它有什麼問題嗎?

    PS:我使用的是OAuth的API:

    $connection = new TwitterOAuth(CONSUMER_KEY, CONSUMER_SECRET, $access_token['oauth_token'], $access_token['oauth_token_secret']); 
    

    回答

    0

    如果我沒有記錯的話,你不需要添加一個「id」參數。

    查看Twitter's Documentation創建收藏的網址爲http://api.twitter.com/1/favorites/create/12345.xml,其中「12345」是推文的ID。

    +0

    他正在通過'array('id'=> $ fav)'來做這件事。 – shamittomar 2010-09-05 16:47:11

    +0

    我得到了ID但錯誤地構建了URL。 – CLiown 2010-09-05 17:39:31

    0

    當我試了一下,下面說。

    該方法需要GET。

    儘管Twitter API 文檔表示它需要POST。所以,試着做就可以了GET要求:

    $response = $connection->get('favorites/create', array('id' => $fav)); 
    // now print the response to see if any error pops up: 
    print_r($response); 
    
    +0

    這是使用OAuth,$連接令牌。 – CLiown 2010-09-05 15:59:41

    +0

    @danit,答案已更新。 – shamittomar 2010-09-05 16:35:44

    +0

    我得到[error] =>未使用獲得授權 – CLiown 2010-09-05 17:13:24

    1
    $response = $connection->post('favorites/create/'.$fav); 
    

    該ID不是參數。

    1

    我試着用下面的PHP的最愛我的帳戶:

    $favorite = $connection->post('favorites/create/'.$id); 
    

    其中$id是狀態ID,但最喜歡的不返回任何

    相關問題