From 135b80a792a6a2088fd249469e09bf41aed6fce7 Mon Sep 17 00:00:00 2001 From: Rafael Bardini Date: Wed, 9 Apr 2014 01:41:59 +0000 Subject: [PATCH] Migrate Twitter hook example to API v1.1 The Twitter REST API v1 is no longer active. See https://dev.twitter.com/discussions/18560 for details. --- example-hooks/post_twitter.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/example-hooks/post_twitter.php b/example-hooks/post_twitter.php index 5803b5a..f53f621 100644 --- a/example-hooks/post_twitter.php +++ b/example-hooks/post_twitter.php @@ -165,7 +165,7 @@ function tweet_link_to_post(array $post_array_for_template) $short_url_length = 24; // Big, safe default (at time of writing, Twitter's value is actually 20) try { - $config = json_decode($oauth->request('GET', 'http://api.twitter.com/1/help/configuration.json'), true); + $config = json_decode($oauth->request('GET', 'http://api.twitter.com/1.1/help/configuration.json'), true); if (isset($config['short_url_length'])) $short_url_length = intval($config['short_url_length']); if ($short_url_length < 16) $short_url_length = 24; // sanity check } catch (Exception $e) { } @@ -179,7 +179,7 @@ function tweet_link_to_post(array $post_array_for_template) $tweet_text .= ' ' . $url_to_use; $response = $oauth->request( - 'POST', 'https://api.twitter.com/1/statuses/update.json', + 'POST', 'https://api.twitter.com/1.1/statuses/update.json', array('trim_user' => 'true', 'status' => $tweet_text) ); @@ -200,7 +200,7 @@ function tweet_link_to_post(array $post_array_for_template) $oauth->token = TwitterPostHookCredentials::$access_token; $oauth->token_secret = TwitterPostHookCredentials::$access_token_secret; - $response = $oauth->request('GET', 'https://api.twitter.com/1/account/verify_credentials.json'); + $response = $oauth->request('GET', 'https://api.twitter.com/1.1/account/verify_credentials.json'); $user = @json_decode($response, true); if ($user && isset($user['error'])) {