Changing to API v1.1 with java script problem


#1

Hi

I’ve got a problem with the below java script which currently calls the old 1v of the api.
Any help on how to change the script to make it work again? Tried putting /1.1/

$(document).ready(function() {
// set your twitter id
var user = 'studio_dog';
var userLink = 'http://twitter.com/#!/studio_dog';
var HTML = '';  
// using jquery built in get json method with twitter api, return only one result
//$.getJSON('http://twitter.com/statuses/user_timeline.json?screen_name=' + user + '&count=3&callback=?', function(data) {
//$.getJSON('http://search.twitter.com/search.json?q=from:STUDIO_DOG&count=3&callback=?', function(data) {
$.getJSON('https://api.twitter.com/1/statuses/user_timeline.json?include_entities=true&include_rts=true&screen_name=STUDIO_DOG&count=3&callback=?', function(data) {
    
	
    
	// result returned
    var tweet1 = data[0].text;
     // process links and reply
    tweet1 = tweet1.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, function(url) {
        return '<a href="'+url+'">'+url+'</a>';
    }).replace(/B@([_a-z0-9]+)/ig, function(reply) {
        return  reply.charAt(0)+'<a href="http://twitter.com/%27+reply.substring%281%29+%27">'+reply.substring(1)+'</a>';
    });
    
    var tweet2 = data[1].text;
     // process links and reply
    tweet2 = tweet2.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, function(url) {
        return '<a href="'+url+'">'+url+'</a>';
    }).replace(/B@([_a-z0-9]+)/ig, function(reply) {
        return  reply.charAt(0)+'<a href="http://twitter.com/%27+reply.substring%281%29+%27">'+reply.substring(1)+'</a>';
    });
    
    var tweet3 = data[2].text;
     // process links and reply
    tweet3 = tweet3.replace(/(\b(https?|ftp|file):\/\/[-A-Z0-9+&@#\/%?=~_|!:,.;]*[-A-Z0-9+&@#\/%=~_|])/ig, function(url) {
        return '<a href="'+url+'">'+url+'</a>';
    }).replace(/B@([_a-z0-9]+)/ig, function(reply) {
        return  reply.charAt(0)+'<a href="http://twitter.com/%27+reply.substring%281%29+%27">'+reply.substring(1)+'</a>';
    });
    
    HTML += "<div class='twitter-feed active'>\
        <p><a href='" + userLink + "'>STUDIO_DOG</a>: " + tweet1 + " <a href='" + userLink + "'>[tweet]</a></p>\
    </div>\



STUDIO_DOG: " + tweet2 + " [tweet]





STUDIO_DOG: " + tweet3 + " [tweet]


";
    // output the result
    $("#twitter_response").append(HTML);
});

});


#2

API v1.1 requires authentication which makes this kind of client-side Javascript difficult or impossible to perform securely. For something as custom as this, you’ll need to use server-side programming instead. Also take a look at [node:10248].


#3

Ah, ok thanks for the bad news. Thought the developer who originally made it had gone quiet on me for a reason.

Thanks for the swift answer.


#4

Hello all
I have a problem with a software like exchange, also includes the software twitter link "http://www.rsexchanger.it/."
When applying for twitter account and is part says "Twitter does not exist!"
actually goes wrong.
the files that manage the twitter are 2
twitter.php

<? include('header.php');

if(!$is_online){
redirect(‘index.php’);
exit;
}

$sql = $db->Query(“SELECT id FROM twitter WHERE active=‘0’ AND user=’”.$data[‘id’]."’");
$query = $db->GetNumRows($sql);

$sql = $db->Query(“SELECT id,t_name,t_av,cpc FROM twitter WHERE (active = ‘0’ AND points >= cpc) AND (id NOT IN (SELECT site_id FROM followed WHERE user_id=’”.$data[‘id’]."’) AND user!=’".$data[‘id’]."’) ORDER BY cpc DESC LIMIT 7");
$ext = $db->GetNumRows($sql);
$sites = $db->FetchArrayAll($sql);
?>

Guadagna gettoni - Twitter

<? if($query > 0){ if($ext > 0){ ?>

Premere il tasto "Segui" in questa pagina e poi premere il tasto "Follow" a pagina Twitter. Dopo di che, premere su "Conferma".

<? foreach($sites as $site){ ?>
@<?=$site['t_name']?>
Coins: <?=$site['cpc']?>
Follow Confirm [skip]
<?}?>

<?}else{?>
Siamo spiacenti, non ci sono più gettoni da guadagnare in questo momento. Riprova più tardi.
<?}}else{?> <?}?>
<?include('footer.php');?>

and twitterconfig.php

<?php include('header.php'); if(!$is_online){ redirect('index.php'); exit; } $tw1 = $db->Query("SELECT * FROM `twitter` WHERE `user`='".$data['id']."' AND `active`='0'"); $tw = $db->FetchArray($tw1); if(isset($_POST['submit']) && $_POST['name'] != "") { $name = $db->EscapeString($_POST['name']); $sql = $db->Query("SELECT id FROM `twitter` WHERE `t_name`='".$name."' AND `user`='".$data['id']."'"); $ext = $db->GetNumRows($sql); if($ext > 0){ $db->Query("UPDATE `twitter` SET `active`='0' WHERE `t_name`='".$name."' AND `user`='".$data['id']."'"); $mesaj = '
Twitter successfully added!
'; $h = 1; }else{ $sql = $db->Query("SELECT id FROM `twitter` WHERE `t_name`='".$name."'"); $num = $db->GetNumRows($sql); if($num > 0){ $mesaj = '
Twitter already exist!
'; }else{ $url = get_data("https://api.twitter.com/1/account/verify_credentials.json?screen_name=".$name); $xml = json_decode($url, true); $id = $xml[0]['id']; $av = $xml[0]['profile_image_url']; if ($id != "") { $db->Query("INSERT INTO `twitter` (user, t_name, t_id, t_av) VALUES('".$data['id']."', '".$name."', '".$id."', '".$av."')"); $mesaj = '
Twitter successfully added!
'; $h = 1; }elseif($xml['error'] != ''){ $mesaj = '
Twitter says: '.$xml['error'].'
'; }else{ $mesaj = '
Twitter doesn\'t exist!
'; }} }} if($_GET['a'] == "del"){ $cpc = $db->EscapeString($_POST['cpc']); $db->Query("UPDATE `users` SET `coins`=`coins`+'".$tw['points']."' WHERE `id`='".$data['id']."'"); $db->Query("DELETE FROM `twitter` WHERE `user`='".$data['id']."'"); $db->Query("DELETE FROM `followed` WHERE `site_id`='".$tw['id']."'"); redirect("twitterconfig.php"); }?>

Twitter Account

<? echo $mesaj; ?> <? if($_GET['a'] == "cpc"){ if(isset($_POST['editcpc']) && $_POST['cpc'] > 0 && $_POST['cpc'] <= 5){ $cpc = $db->EscapeString($_POST['cpc']); $db->Query("UPDATE `twitter` SET `cpc`='".$cpc."' WHERE `t_name`='".$tw['t_name']."' AND `user`='".$data['id']."'"); echo '
CPC successfully changed!
'; } ?>

CPC*
1 Coin >2 Coins >3 Coins >4 Coins >5 Coins<?if($data['premium'] > 0){?> >6 Coins >7 Coins >8 Coins >9 Coins >10 Coins<?}?>

* Monete per click.

<? }elseif($tw['t_name'] != ""){?>
<?=$tw['t_name']?> (Delete)
Coins: <?=$tw['points']?> (Add)
CPC: <?=$tw['cpc']?> (Edit)
<?}elseif(isset($_POST['submit']) && $h == 1){?>

<?=$_POST['name']?><?}else{?>
Twitter Username
Se non aggiungi il tuo vero nome utente Twitter, utilizzato nello scambio, non si possono guadagnare monete.
<?}?>
<?include('footer.php');?>

I can lend a hand to make it work?