PHP通过网页链接将图片发布到Twitter


PHP Posting Images to Twitter with Link to Webpage?

我很难在twitter API 中使用"链接缩短"服务

https://dev.twitter.com/docs/tco-link-wrapper/faq

我的印象是,当一个标准类型的链接通过API时,它应该自动变短并可点击。然而,无论我如何发送链接,它总是不可点击的文本。。。从不缩短,并且总是在140的限制范围内计数。

当使用1.1 api时,我们如何指导twitter处理URL?

//this here is simply binary stuff uploaded and posted, using twitteroath library
$media = ss_get_image_binary($file_attachment_path);            
$params = array(
    'media[]' => "{$media};type=image/jpeg;filename={$file_attachment_path}",           
);      
$resource_url = 'https://api.twitter.com/1.1/statuses/update_with_media.json';

链接部分:

//I'm making my own hashtags, and counting post length stuff myself...
//the backlink variable here is just a typical http: link
$hashtags = ss_make_hastags($tags, $id);    
$title = ss_twitter_status_format($image->post_title, $hashtags);
$backlink = get_permalink($id);
$params['status'] = $backlink . ' ' . $hashtags;

//最后,所有内容都发布到twitter

$connection = ss_twitter_communication_setup(); 
$tweet = $connection->post($resource_url, $params);

图片和状态发布良好。链接永远不会变为"活动"或可点击。他们的人数超过了140人的限制。

还有一件事——

这是所有东西都指向的类,设置通信

$connection = new TwitterOAuth($cons_key, $cons_secret, $oauth_token, $oauth_token_secret);

发现问题:

LOCALHOST不工作。

facepalm