0

So I have this bit as a part of the a code that came with the html template that I purchased. I was told that in order for this to work, I need to use the absolute URL of 'api/tweet.php'.

This is all I one line:

 (function($){$.fn.twittie=function(options){var settings=$.extend({'count':10,'hideReplies':false,'dateFormat':'%b/%d/%Y','template':'{{date}} - {{tweet}}'},options);var linking=function(tweet){var parts=tweet.split(' ');var twit='';for(var i=0,len=parts.length;i<len;i++){var text=parts[i];var link="https://twitter.com/#!/";if(text.indexOf('#')!==-1){text='<a href="'+link+'search/'+text.replace('#','%23').replace(/[^A-Za-z0-9]/,'')+'" target="_blank">'+text+'</a>'}if(text.indexOf('@')!==-1){text='<a href="'+link+text.replace('@','').replace(/[^A-Za-z0-9]/,'')+'" target="_blank">'+text+'</a>'}if(text.indexOf('http://')!==-1){text='<a href="'+text+'" target="_blank">'+text+'</a>'}twit+=text+' '}return twit};var dating=function(twt_date){var time=twt_date.split(' ');twt_date=new Date(Date.parse(time[1]+' '+time[2]+', '+time[5]+' '+time[3]+' UTC'));var months=['January','February','March','April','May','June','July','August','September','October','November','December'];var _date={'%d':twt_date.getDate(),'%m':twt_date.getMonth()+1,'%b':months[twt_date.getMonth()].substr(0,3),'%B':months[twt_date.getMonth()],'%y':String(twt_date.getFullYear()).slice(-2),'%Y':twt_date.getFullYear()};var date=settings.dateFormat;var format=settings.dateFormat.match(/%[dmbByY]/g);for(var i=0,len=format.length;i<len;i++){date=date.replace(format[i],_date[format[i]])}return date};var templating=function(data){var temp=settings.template;var temp_variables=['date','tweet','avatar'];for(var i=0,len=temp_variables.length;i<len;i++){temp=temp.replace(new RegExp('{{'+temp_variables[i]+'}}','gi'),data[temp_variables[i]])}return temp};this.html('<span>Loading...</span>');var that=this;$.getJSON('api/tweet.php',{count:settings.count,exclude_replies:settings.hideReplies},function(twt){that.find('span').fadeOut('fast',function(){that.html('<ul></ul>');for(var i=0;i<settings.count;i++){if(twt[i]){var temp_data={date:dating(twt[i].created_at),tweet:linking(twt[i].text),avatar:'<img src="'+twt[i].user.profile_image_url+'" />'};that.find('ul').append('<li>'+templating(temp_data)+'</li>')}else{break}}})})}})(jQuery);

Does anyone know how to use or get the absolute URL of tweet.php? I've tried researching or doing a google search on it but none seem to work.

The location of the tweet.php is

http://exampledomain.com/api/tweet.php

EDIT: This is the thread discussion that I posted on their support website. I didn't share the link since it requires visitors to open an account with them just to view responses

Support Thread Picture

chumakoff
  • 6,807
  • 2
  • 23
  • 45
az27527
  • 23
  • 6
  • what kind of output do you want? – Adhan Timothy Younes Mar 18 '17 at 06:22
  • Actually, you show us the minified source code of the [Twittie jQuery plugin](https://github.com/sonnyt/Tweetie). – Damien Flament Mar 18 '17 at 06:29
  • Concerning the absolute URL, `http://exampledomain.com/api/tweet.php` is absolute! I think you should clarify your question: Where did you need to put this absolute URL ? I think you're talking about the [_apiPath_ option](https://github.com/sonnyt/Tweetie#options). – Damien Flament Mar 18 '17 at 06:35
  • Show us the JavaScript source code which call and configure the Twittie plugin. And maybe we can help you. – Damien Flament Mar 18 '17 at 06:37
  • In the code is absolute already -> $.getJSON('api/tweet.php' – Scaffold Mar 18 '17 at 06:51
  • @Scaffold: I think it isn't: http://stackoverflow.com/questions/2005079/absolute-vs-relative-urls. `/api/tweet.php` is relative to the document root, `api/tweet.php` is not. – Damien Flament Mar 18 '17 at 08:51
  • Absolute in two. parent absolute ->api/tweet.php , root absolute /api/tweet.php – Scaffold Mar 18 '17 at 08:59
  • I edited the original question and included the thread when I asked the question on the support website of the seller where I purchased the template. It specifically said, I need to use Absolute URL but anyway, I tried using "http://exampledomain.com/api/tweet.php" and "/home/usr/public_html/api/tweet.php" and neither worked. I am not very familiar with PHP, so I thought it would need to find the document root (this is just based on my Google search. – az27527 Mar 18 '17 at 15:30
  • It's difficult to help you has it seems that you don't have many knowledges about web development. The first thing to do is to use the web browser development tools to watch for the loaded files (within the Network tab). If the Tweetie file is not loaded, the issue is not related to the plugin configuration. Moreover, you can use the JavaScript console to show errors. – Damien Flament Mar 28 '17 at 01:28
  • @Scaffold: If an URL is related to something (the root or the current directory), it's not absolute, it's relative! api/tweet.php --> relative to the current directory, /api/tweet.php --> relative to the root directory. – Damien Flament Mar 28 '17 at 01:29
  • The Tweetie plugin seems to work on your website. So, how do you fix it ? – Damien Flament Mar 28 '17 at 01:40

1 Answers1

0

According to the Tweetie jQuery plugin documentation, you have to use the apiPath option:

$('.foo').twittie({
    'apiPath': 'http://exampledomain.com/api/tweet.php',
});

But specifying the domain is discouraged and unnecessary. So :

$('.foo').twittie({
    'apiPath': '/api/tweet.php',
});
Damien Flament
  • 1,465
  • 15
  • 27