Twitter API를 통해 특정 다른 사용자 (예 : @Google)를 팔로우하는 사용자의 모든 Twitter ID를 검색하고 싶습니다. 요청이 Postman에서 작동하는 동안 PHP에서 작동하도록 할 수 없습니다. $ userids는 문자열이 아니므로 json_decode에서 처리 할 수 없습니다. 아래 코드. 당신의 도움을 주셔서 감사합니다!
<?php
require "twitteroauth/autoload.php";
use Abraham\TwitterOAuth\TwitterOAuth;
ini_set('max_execution_time', 600);
ini_set('memory_limit', '1024M');
$consumerKey = 'redacted';
$consumerKeySecret = 'redacted';
$accessToken = 'redacted';
$accessTokenSecret = 'redacted';
$cursor = -1; // first page
$connection = new TwitterOAuth($consumerKey, $consumerKeySecret, $accessToken, $accessTokenSecret);
$content = $connection->get("account/verify_credentials");
$userids = $connection->get("followers/ids", ["cursor" => -1, "screen_name" => "google", "count" => 5000]);
echo $userids;
$data = json_decode($userids);
foreach ($data as $ids => $value) {
// tbd
}
var_dump($data);
?>
$ userids는 TwitterOAuth 소스에서 볼 수 있듯이 배열입니다.
$response = JsonDecoder::decode($result, $this->decodeJsonAsArray);
즉, 이미 PHP 배열이므로 다시 json_decode () 할 필요가 없습니다.
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다