Twitter Bot PHP
1.0.0
PHPを使用したメディアとともに、ステータスを自動的に更新するためのTwitterボット。
Twitter開発者アカウントにアプリを登録します
開発者ページからアプリケーションを登録します。消費者の秘密を決して明らかにしないことを忘れないでください。これで、消費者キー、コンシューマーシークレット、アクセストークン、アクセストークンシークレットができました。
CodeBird-PHPをダウンロードします
CodeBirdを使用して、Twitter Rest API、ストリーミングAPI、Collections API、Ton(Object Nest)API、PHPコードのTwitter ADS APIに接続します。すべて1つのライブラリを使用します。 CodeBirdは、完全な3ウェイOAUTHとアプリケーションのみの認証をサポートしています。
こちらからまたはこちらからダウンロードできます
メッセージの送信:グループまたはチャネルにメッセージを送信します。
$ ApiKey = < API_KEY >;
$ ApiSecretKey = < API_SECRET_KEY >;
$ AccessToken = < ACCESS_TOKEN >;
$ AccessTokenSecret = < ACCESS_TOKEN_SECRET >;
// add the codebird library
require_once ( ' codebird/src/codebird.php ' );
Codebird Codebird:: setConsumerKey ( $ ApiKey , $ ApiSecretKey );
$ cb = Codebird Codebird:: getInstance ();
$ cb -> setToken ( $ AccessToken , $ AccessTokenSecret );
//build an array of images to send to twitter
$ reply = $ cb -> media_upload ( array (
' media ' => < IMAGE_URL > or < IMAGE_URI >
));
//upload the file to your twitter account
$ mediaID = $ reply -> media_id_string ;
// implode mandatory only for multile media uploads
$ params = array (
' status ' => " #message " ,
' media_ids ' => implode ( ' , ' , [ $ mediaID ]) // optional
);
//post the tweet with codebird
$ reply = $ cb -> statuses_update ( $ params );
function get_content ( $ URL )
{
$ ch = curl_init ();
curl_setopt ( $ ch , CURLOPT_RETURNTRANSFER , 1 );
curl_setopt ( $ ch , CURLOPT_URL , $ URL );
$ data = curl_exec ( $ ch );
curl_close ( $ ch );
return $ data ;
}
あなたが私の仕事に感謝しているなら、私を充電し続けるために私に一杯の☕を買うことを検討してください? PayPalによって
Copyright 2020 MyInnos
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.