Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

engagement endpoint #288

Open
ghadayoussef opened this issue Feb 6, 2020 · 0 comments
Open

engagement endpoint #288

ghadayoussef opened this issue Feb 6, 2020 · 0 comments

Comments

@ghadayoussef
Copy link

I'm trying to hit the engagement endpoint but it always return status code :400 ,does anyone understand why ?
function getEngagement($token,$tokenSecret){
$settings = array(
'oauth_access_token' => $token,
'oauth_access_token_secret' => $tokenSecret,
'consumer_key' => env('TWITTER_CONSUMER_KEY'),
'consumer_secret' => env('TWITTER_CONSUMER_SECRET')
);

    //$url = 'https://data-api.twitter.com/insights/engagement/totals';
    $url = 'https://data-api.twitter.com/insights/engagement/28hr';
    $requestMethod = 'POST';
   $postfields = array(
        'tweet_ids'=>array('1217776265337475073',
          '1217183078503845893'),
          'engagement_types'=> array(
            'impressions',
           ' engagements',
           ' url_clicks',
            'detail_expands'
          ),
        'groupings'=> array(
            'grouping name'=> array(
            'group_by'=>array(
              "tweet.id",
              "engagement.type",
              "engagement.hour"
            )))
          
        );
    
    $engagement = new TwitterAPIExchange($settings);
    $engagement->buildOauth($url, $requestMethod)->performRequest(true, [
                CURLOPT_HTTPHEADER => array('Content-Type:application/json','Accept-Encoding:gzip'),
                CURLOPT_POSTFIELDS => json_encode($postfields)
                ]);
    dd($engagement);


}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant