php - How can I find out why a WordPress theme breaks my website? -
i got theme on wordpress , when setting theme tried use twitter functionality, although part of code me embed 1 of tweets page break website.
all of api tokens have been added previous sections of code well, makes me think wrong , there syntax error.
<?php function buildbasestring($baseuri, $method, $params) { $r = array(); ksort($params); foreach($params $key=>$value){ $r[] = "$key=" . rawurlencode($value); } return $method."&" . rawurlencode($baseuri) . '&' . rawurlencode(implode('&', $r)); } function buildauthorizationheader($oauth) { $r = 'authorization: oauth '; $values = array(); foreach($oauth $key=>$value) $values[] = "$key=\"" . rawurlencode($value) . "\""; $r .= implode(', ', $values); return $r; } $url = "https://api.twitter.com/1.1/statuses/user_timeline.json"; $oauth_access_token = $tweet_token; $oauth_access_token_secret = $tweet_token_secret; $consumer_key = $tweet_key; $consumer_secret = $tweet_key_secret; $oauth = array( 'screen_name' => $tweet_user, 'count' => 1, 'oauth_consumer_key' => $consumer_key, 'oauth_nonce' => time(), 'oauth_signature_method' => 'hmac-sha1', 'oauth_token' => $oauth_access_token, 'oauth_timestamp' => time(), 'oauth_version' => '1.0'); $base_info = buildbasestring($url, 'get', $oauth); $composite_key = rawurlencode($consumer_secret) . '&' . rawurlencode($oauth_access_token_secret); $oauth_signature = base64_encode(hash_hmac('sha1', $base_info, $composite_key, true)); $oauth['oauth_signature'] = $oauth_signature; // make requests $header = array(buildauthorizationheader($oauth), 'expect:'); $options = array( curlopt_httpheader => $header, //curlopt_postfields => $postfields, curlopt_header => false, curlopt_url => $url . '?screen_name='.$tweet_user.'&count=1', curlopt_returntransfer => true, curlopt_ssl_verifypeer => false); $feed = curl_init(); curl_setopt_array($feed, $options); $json = curl_exec($feed); curl_close($feed); $twitter_data = json_decode($json); $out ='<ul id="twitter">'; foreach ($twitter_data $key=>$value) { $regex = '@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.\,]*(\?\s+)?)?)*)@'; $text = $value->text; $text = preg_replace('@(https?://([-\w\.]+)+(:\d+)?(/([\w/_\./-]*(\?\s+)?)?)?)@', '<a target="blank" title="$1" href="$1">$1</a>', $text); $text = preg_replace('/#([0-9a-za-z_-]+)/', "<a target='blank' title='$1' href=\"http://twitter.com/search?q=$1\">#$1</a>", $text); $text = preg_replace("/@([0-9a-za-z_-]+)/", "<a target='blank' title='$1' href=\"http://twitter.com/$1\">@$1</a>", $text); $out .='<li>' . $text . '</li>'; }; $out .='</ul>'; echo $out; ?>
Comments
Post a Comment