Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/php/230.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Php 从twitter API发送直接消息_Php_Twitter - Fatal编程技术网

Php 从twitter API发送直接消息

Php 从twitter API发送直接消息,php,twitter,Php,Twitter,我正试图通过API将内部服务器通知通过直接消息发送给我自己和其他工作人员。我已经在dev.twitter上完成了API设置,并下载了库 我需要在哪里寻找直接从服务器(通过我的帐户)发送消息,而不必每次使用浏览器登录?我上次使用twitterapi是在oauth之前,所以已经过了相当长的一段时间 tl;dr需要通过twitter发送直接消息而不看到此信息您可以在应用程序页面上获取您的个人代币,并使用它,而无需使用twitter登录 在应用程序页面的“OAuth设置”部分下,获取: 消费者密钥 消

我正试图通过API将内部服务器通知通过直接消息发送给我自己和其他工作人员。我已经在dev.twitter上完成了API设置,并下载了库

我需要在哪里寻找直接从服务器(通过我的帐户)发送消息,而不必每次使用浏览器登录?我上次使用twitterapi是在oauth之前,所以已经过了相当长的一段时间


tl;dr需要通过twitter发送直接消息而不看到此信息

您可以在应用程序页面上获取您的个人代币,并使用它,而无需使用twitter登录

在应用程序页面的“OAuth设置”部分下,获取:

  • 消费者密钥
  • 消费者的秘密
您的访问令牌下
获取:

  • 访问令牌
  • 访问令牌是一个秘密
检查访问级别是否为“读、写和直接消息”。否则,在
设置
选项卡中更改它并重新创建访问令牌(在
详细信息
选项卡底部有一个按钮)

然后在php中

require('Abrahams library');

// Get everything you need from the dev.twitter.com/apps page
$consumer_key = 'APP KEY';
$consumer_secret = 'APP SECRET';
$oauth_token = 'YOUR TOKEN';
$oauth_token_secret = 'YOUR TOKEN SECRET';

// Initialize the connection
$connection = new TwitterOAuth($consumer_key, $consumer_secret, $oauth_token, $oauth_token_secret);

// Send a direct message
$options = array("screen_name" => "theGuyIWantToDM", "text" => "Hey that's my message");
$connection->post('direct_messages/new', $options);

您可以从上的应用程序页面获取您的个人令牌并使用它,而无需使用Twitter登录。