Raised This Month: $ Target: $400
 0% 

substring ! substr(txt,start,end) ?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
ÜnLoCo
Member
Join Date: Dec 2009
Location: 35.77N, 10.82E
Old 05-30-2010 , 09:52   substring ! substr(txt,start,end) ?
Reply With Quote #1

Hello Guys
as you see i'm looking for something simple and useful !
let's say i read this html
http://graph.facebook.com/4
and i want to get just the "name" variable !
which is the function to do that ?
i'm not asking for ready to paste code but just the usage of the function !
the closest thing i got from searching is regex_substr !
is there a simpler way ?
thank youu
__________________
ÜnLoCo is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 05-30-2010 , 10:39   Re: substring ! substr(txt,start,end) ?
Reply With Quote #2

Take a look at these; strfind will return the position of a string within a string.

http://www.amxmodx.org/funcwiki.php?go=inc&id=5
__________________
Bugsy is offline
ÜnLoCo
Member
Join Date: Dec 2009
Location: 35.77N, 10.82E
Old 05-30-2010 , 13:06   Re: substring ! substr(txt,start,end) ?
Reply With Quote #3

Thank You
i had to use regex and strtok !
i do a request by ID and get the name of the user
anybody find his code .. thanks !

PHP Code:
new g_Socket1;
public 
getPlayerDetails(id,fbacc)
{
    new 
Error;
    
g_Socket1 socket_open("graph.facebook.com",80,SOCKET_TCP,Error);

    
    new 
Data1[512];
    
formatex(Data1,511,"GET /%d/ HTTP/1.1^r^nHost:graph.facebook.com^r^nConnection: close^r^n^r^n",fbacc);
    
socket_send(g_Socket1,Data1,511);
    new 
params[2];
    
params[0] = id;
    
params[1] = fbacc;
    
set_task0.5 "CheckForData1" TASK_RECV1 params2"b");
}

public 
CheckForData1(args[])
{
    static 
Data[256]; 
    if ( 
socket_changeg_Socket1 ) )
    {
        
socket_recvg_Socket1 Data 255 );
        {    
            if ( 
containiData "first_name" ) != -1){
            new 
pattern[] = "^"name^":^"(.+)^",^"f"
 
        new num, error[128]
        //str = string
        //pattern = pattern to use
        //num = special return case code
        //error = if there's an error, it will go here
        //127 - error's max length
        new Regex:re = regex_match(Data, pattern, num, error, 127)
        if (re >= REGEX_OK){
            new str2[64]
            new i=0
            regex_substr(re, i, str2, 63)
            new left[200]
            new right[200]
            strtok(str2,left,199,right,199,':')
            strtok(right,left,199,right,199,',')
            new Html[200]
            new fba = args[1]
            new id = args[0]
            format(Html,199,"
<div align=center><b>%s</b><br/><img src=^"http://graph.facebook.com/%d/picture?type=large^"/><br/><i>Copy Profile Link From Console !</i></div>",left,fba)
            show_motd(id,Html,"
Add As Friend")
        }
        remove_task( TASK_RECV1 );
        return PLUGIN_HANDLED;
      }   
        }
    }

getPlayerDetails(id,fbacc) will give you this
//fbacc is the facebook account ID of that user (connected from here http://apps.facebook.com/noexitpro/ )
//id is .. you know



i still have some problems with weird chars !
it's the next step
__________________
ÜnLoCo is offline
Old 05-30-2010, 14:15
infek
This message has been deleted by infek. Reason: didnt read correctly
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 05:19.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode