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

Migrate Twitter hook example to API v1.1 #37

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions example-hooks/post_twitter.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) { }
Expand All @@ -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)
);

Expand All @@ -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'])) {
Expand Down