如何使用OAuth发送直接消息

如何使用OAuth发送直接消息

本文介绍了如何使用OAuth发送直接消息?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试制作一个Twitter应用程序.我的应用程序已经到了用户可以通过Twitter用户验证系统登录的地步.我还可以使用我的应用程序发送状态更新.我具有此功能来发送状态更新:

I am trying to make a twitter application. I have gotten my application to a point where users log in through Twitter's user verification system. I am also able to send status updates using my application. I have this function to send status updates:

function sendTweet($tx){

    $consumer_key = 'MY CONSUMER KEY';
    $consumer_secret = 'MY CONSUMER SECRET';

    $Twitter = new EpiTwitter($consumer_key, $consumer_secret);
    $Twitter->setToken($_SESSION['OT'],$_SESSION['OTS']);

    $text=$tx;
    $status=$Twitter->post_statusesUpdate(array('status' => $text));
    $status->response;

}

sendTweet($tx)函数的作用就像一个超级按钮,但是现在我需要做的是获取用户的关注者列表,然后将直接消息发送给他们.如何使用oauth和PHP做到这一点?

This sendTweet($tx) function works like a charm but now what i need to do is get a list of followers of a user and then send Direct Messages to them. How can I do this using oauth and PHP?

推荐答案

function sendDirectMessage($user,$message)
{       $consumer_key = 'YOUR CONSUMER KEY';
        $consumer_secret = 'YOUR SECRET';

        $Twitter = new EpiTwitter($consumer_key, $consumer_secret);
        $Twitter->setToken($_SESSION['OT'],$_SESSION['OTS']);

        $myArray = array('user' => $user, 'text' => $message);

        $resp = $Twitter->post_direct_messagesNew( $myArray);
        $resp->response;
    }

这篇关于如何使用OAuth发送直接消息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 17:13