Jump to content

Posting a picture to facebook


Recommended Posts

I would like to build a csript which can upload a photo to facebook. But not by clicking on the browse button or antyhing.

I want it to happen invisibly. The user should be able to use the system without any issues.

Is it even possible?

Link to comment
Share on other sites

Don't know if it is possible.

But I'm sure you will run into problems because if the user needs to logon to facebook before he can upload an image you will clearly violate the forum rules.

Especially the part about "SPAM tools including instant messenger or forum auto-posters. This includes forum or site auto-login methods."

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Don't know if it is possible.

But I'm sure you will run into problems because if the user needs to logon to facebook before he can upload an image you will clearly violate the forum rules.

Especially the part about "SPAM tools including instant messenger or forum auto-posters. This includes forum or site auto-login methods."

No the user should be already logged so, I don't have to discuss the logon method. What I am thinking is, I have a page on which I need to post photos every hour or so.

My plan:

  • Login to facebook manually (not the autoit part) in IE.
  • Start the script
  • Enter the page id and image directory
  • get the image one by one from the folder
  • post it to the page for which id is given.
  • wait for some time.
  • Goto step5
  • Stopeed when clicked on the stop button!
I don't think this violates the forum rules. This has only legitimate uses. I just want to schedule the photo posting proecess!
Link to comment
Share on other sites

I don't think this violates the forum rules.

Correct.

When searching the forum I found very few threads related to facebook and API.

This looks to be the place to start searching for APIs: http://developers.facebook.com/docs/reference/api/

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Correct.

When searching the forum I found very few threads related to facebook and API.

This looks to be the place to start searching for APIs: http://developers.facebook.com/docs/reference/api/

I don't want to work with api. API requests has some limitations and so and so.

I was thinking like submitting the form and stuffs like that. Isn't it possible?

--

I just found out this thing, in the mobile version of facebook, we can actually type in the path to the image on our system to the field instead of actually clicking on the browse button and then selecting it. I beleve we can use the IE form actions to enter th path to images easily!

Edited by obscurant1st
Link to comment
Share on other sites

<form method="post" action="[url="http://upload.facebook.com/mobile_upload.php?m_sess=sozCTPRr-gn6zkmo_"]http://upload.facebook.com/mobile_upload.php?m_sess=sozCTPRr-gn6zkmo_"[/url] enctype="multipart/form-data"><input name="fb_dtsg" value="AQDj8tcb" autocomplete="off" type="hidden"><input name="charset_test" value="€,´,€,´,水,Д,Є" type="hidden"><input name="return_uri" value="[url="http://m.facebook.com/lamestjokes?v=feed&amp;fc=0"]http://m.facebook.com/lamestjokes?v=feed&amp;fc=0"[/url] type="hidden"><input name="return_uri_error" value="[url="http://m.facebook.com/upload.php?target=310788438934239"]http://m.facebook.com/upload.php?target=310788438934239"[/url] type="hidden"><input name="id" value="100001054085125" type="hidden"><input name="target" value="310788438934239" type="hidden"><input name="file1" type="file"><br><span class="mfss">Photo caption:</span><br><textarea class="input" rows="2" name="caption"></textarea><br><input value="Upload" class="btn btnC" type="submit"></form>

The above is the form, but there is no name to it. So how can I use _IEFormGetObjByName ?

Edited by obscurant1st
Link to comment
Share on other sites

Have a look at the help file _IEFormGetObjByName:

Remarks: "If the desired form does not have a name or ID, _IEFormGetCollection to get a reference by index"

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

While $filecount < $filelist[0]
$imgpath = $folder & "" & $filelist[$filecount]
$filecount = $filecount+1
$iewindow = _IECreate($fbuploadurl, 0, 1, 1, 1)
$ieformname = _IEFormGetCollection($iewindow, 0)
$ieformobj = _IEFormElementGetCollection($ieformname, "6")
_IEFormElementSetValue($ieformobj, $imgpath)
$ieformobj2 = _IEFormElementGetObjByName($ieformobj2, "caption")
_IEFormElementSetValue($ieformobj2, "lolololol! <3")
;_IEFormSubmit($ieformname)
WEnd

This is not working. I guess I am not getting the index concept right. Can you please tell me Whats the thing I am doing wrong?

_IEFormElementSetValue($ieformobj, $imgpath) <- this is the part where it doesn't do anything! :/

Link to comment
Share on other sites

Thanks, but if my way works that would be awesome. If it works then I don't want to waste time on rewriting this stuff, also libcurl is pretty new concept for me! :/

Link to comment
Share on other sites

obscurant1st,

your script needs some error checking.

Check @error after each call of an _IE* function. If @error <> 0 then there was a problem.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

obscurant1st,

your script needs some error checking.

Check @error after each call of an _IE* function. If @error <> 0 then there was a problem.

The problem is, "I don't know what is index". Is it the number of the input element or something else?

$ieformobj = _IEFormElementGetCollection($ieformname, "6")
_IEFormElementSetValue($ieformobj, $imgpath)

Once when I changed that number ("6") in the first line above, the upload button changed to show the data in $imgpath.

Link to comment
Share on other sites

I think the index should be an integer:

$ieformobj = _IEFormElementGetCollection($ieformname, 6)
This will return an object to the 6th element in the form.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

I think the index should be an integer:

$ieformobj = _IEFormElementGetCollection($ieformname, 6)
This will return an object to the 6th element in the form.

This error is showing up!

--> IE.au3 V2.4-0 Error from function _IEFormElementSetValue, $_IEStatus_InvalidObjectType (Browser securuty prevents SetValue of TYPE=FILE)

So I would need to find a way to do this in another means! :/
Link to comment
Share on other sites

Could you please post your solution? It might be useful for others in the future.

My UDFs and Tutorials:

Spoiler

UDFs:
Active Directory (NEW 2024-07-28 - Version 1.6.3.0) - Download - General Help & Support - Example Scripts - Wiki
ExcelChart (2017-07-21 - Version 0.4.0.1) - Download - General Help & Support - Example Scripts
OutlookEX (2021-11-16 - Version 1.7.0.0) - Download - General Help & Support - Example Scripts - Wiki
OutlookEX_GUI (2021-04-13 - Version 1.4.0.0) - Download
Outlook Tools (2019-07-22 - Version 0.6.0.0) - Download - General Help & Support - Wiki
PowerPoint (2021-08-31 - Version 1.5.0.0) - Download - General Help & Support - Example Scripts - Wiki
Task Scheduler (2022-07-28 - Version 1.6.0.1) - Download - General Help & Support - Wiki

Standard UDFs:
Excel - Example Scripts - Wiki
Word - Wiki

Tutorials:
ADO - Wiki
WebDriver - Wiki

 

Link to comment
Share on other sites

Could you please post your solution? It might be useful for others in the future.

$iewindow = _IECreate($fbuploadurl, 0, 0, 1, 1)
;_IEAction($iewindow,"invisible")
$ieformname = _IEFormGetCollection($iewindow, 0)
$ieformobj = _IEFormElementGetCollection($ieformname, 6)
_IEAction($ieformobj, "focus")
_IEAction($ieformobj, "selectall")
Local $hIE = _IEPropertyGet($iewindow, "hwnd")
ControlSend($hIE, "", "[CLASS:Internet Explorer_Server; INSTANCE:1]", $imgpath)

But this works for only ie6. So currently I am using a Vm with ie6 in that.

I am yet to find out a way to do this in IE9/8 :(

Link to comment
Share on other sites

Do anyone know anyway to click on browse and select the image without actually showing the windows, I would like to do it hidden so that user can normally use the computer? :D

Link to comment
Share on other sites

  • 1 year later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...