Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/excel/24.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
Twitter 用OAuth在推特上发送图片_Twitter_Oauth - Fatal编程技术网

Twitter 用OAuth在推特上发送图片

Twitter 用OAuth在推特上发送图片,twitter,oauth,Twitter,Oauth,我使用以下代码与OAuth一起推特图片。我在几个教程中发现了相同的代码,但是如果没有错误发生,我就无法让它工作 <?php // Insert your keys/tokens $consumerKey = '***'; $consumerSecret = '***'; $OAuthToken = '***'; $OAuthSecret = '***'; // Full path to twitterOAuth.php (change OAuth to your own path) re

我使用以下代码与OAuth一起推特图片。我在几个教程中发现了相同的代码,但是如果没有错误发生,我就无法让它工作

<?php
// Insert your keys/tokens
$consumerKey = '***';
$consumerSecret = '***';
$OAuthToken = '***';
$OAuthSecret = '***';

// Full path to twitterOAuth.php (change OAuth to your own path)
require_once('connect/twitter/twitteroauth.php');

$params = array(
    'status' => 'Testing API http://google.com',
    'media[]' => 'http://diit.cz/sites/default/files/google_chrome_logo.png'
);

// create new instance
$tweet = new TwitterOAuth($consumerKey, $consumerSecret, $OAuthToken, $OAuthSecret);

// Send tweet
$tweet->post('statuses/update', $params);
?>

只是想确定一下。$OAuthToken和$OAuthSecret是否应该从Twitter开发者复制?或者这些变量对于每个用户都不同

到目前为止,我已经检查了复制twitter密钥和机密的错误,检查了twitteroatuh.php文件是否正确链接,检查了我的twitter应用程序是否设置为读/写权限,检查了我的服务器上是否启用了cURL


执行此代码后,不会出现任何错误,也不会在我的Twitter上发布任何内容。

媒体必须是本地图像-您不能简单地发布URL。你有没有试过在你的服务器上保存图片并发布?是的,我试过了。它在推特上显示测试结果,但没有图像