Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 5986229
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T22:38:32+00:00 2026-05-22T22:38:32+00:00

I want use php curl with oauth to get the JSON data from twitter

  • 0

I want use php curl with oauth to get the JSON data from twitter. Here is my code. return na error message "error":"Timestamp out of bounds".

I want to know, how to make a correct twitter api curl with oauth?

  1. what is oauth_consumer_key, oauth_token, oauth_nonce, oauth_signature? am I right?

  2. how to solve "error":"Timestamp out of bounds"?

  3. how about my curl_setopt method?

In many way, I would like to use this php curl to decode other twitter api(changed url). Thanks a lot.

$callback="<callback url>";
$consumer_key="<Consumer key>";
$consumer_secret="<Consumer secret>";
$oauth_token="<Access Token (oauth_token)>";
$oauth_signature="<Access Token Secret (oauth_token_secret)>";//these key word in my api panel
$time = mktime(date("Y-m-d H:i:s"))-86400;
$url = "https://api.twitter.com/1/friends/ids.json?";
$url .= "user_id=<user id>";
$url .= "&realm=".urlencode($callback)."";
$url .= "&service_provider_id=11";
$url .= "&oauth_consumer_key=".$consumer_key."";
$url .= "&oauth_token=".$oauth_token."";
$url .= "&oauth_nonce=".$consumer_secret."";
$url .= "&oauth_signature_method=HMAC-SHA1";
$url .= "&oauth_timestamp=".$time."";
$url .= "&oauth_version=1.0";
$url .= "&oauth_signature=".$oauth_signature."";
$ch = curl_init($url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_BINARYTRANSFER, true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Host: api.twitter.com'));
$json = curl_exec($ch);
curl_close ($ch);
$data = json_decode($json, true);
print_r($json);
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T22:38:33+00:00Added an answer on May 22, 2026 at 10:38 pm

    You’re using mktime incorrectly, it doesn’t accept a date string. Instead of that however, I’d recommend that you do …

    $time = time() - 86400;
    

    With regards to your other questions, I recommend getting an oauth capable twitter library for PHP. There are plenty out there, and there’s no point in reinventing the wheel … usually 🙂

    https://dev.twitter.com/docs/auth/oauth/single-user-with-examples

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to use PHP (possibly with Curl/XPath?) to extract data from Wikipedia pages.
I want to execute a php-script from php that will use different constants and
I want to use curl to retrieve a table from an external page. So
I'm trying to learn how to use CURL and Json to access data sent
I want to use php in console mode and create an environment to test
Why would I want to use PHP's filter library? Why wouldn't I? It seems
I want to use the php simple HTML DOM parser to grab the image,
I'd love to use PHP variables in my CSS files but I don't want
Hi have some forms that I want to use some basic php validation (regular
I am writing a web application using PHP. I want to use the MVC

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.