Что нового

Загрузка фото\картинок в группу facebook

chernobeloe

Новичок
Сообщения
33
Репутация
0
Привет привет всем! ;D

Вообщем множественные попытки загрузки картинок в группу в facebook через запросы не увенчаются успехом, и в долгих поисках подсказок и по форуму и в гугле наткнулся на http://autoit-script.ru/index.php?topic=15218.0
воистину вдохновившись находкой и поняв, что она может послужить хорошим примером, начал стряпать по его подобию, но увы все тщетно

Код:
#include <WinHttp.au3>
#include <WinHttpConstants.au3>
#include <String.au3>

Func _FBStart()
	Local $HOST = "m.facebook.com"
	Local $hSession = _WinHttpOpen("Mozilla/5.0 (Windows NT 6.1; rv:42.0) Gecko/20100101 Firefox/43.0")
	If @error Then
		Return SetError(1, 0, 0)
	Else
		Local $HTTP_ConnectFB = _WinHttpConnect($hSession, $HOST, $INTERNET_DEFAULT_HTTPS_PORT)
		If @error Then
			Return SetError(2, 0, 0)
		Else
			Return $HTTP_ConnectFB
		EndIf
	EndIf
EndFunc


Global $startttttttt = _FBStart()
$login = _FBLogin()


Func _FBLogin()
    ;$Email = StringReplace($Email, '@', '%40', 1)
	$Email = '[email protected]'
	$Password = '*******'
	$profile_id = '100009991****'
	$target_group = '6600125****'
	If @error Then
		Return SetError(1, 0, 0)
	Else
		Local $HTML = _WinHttpSimpleSSLRequest($startttttttt, "GET", "", Default, Default, Default, 1)
		If @error Then
			Return SetError(2, 0, 0)
		Else
			;;;;;;;;;;;FileWrite("m.fb.com.html", $HTML[1])
			Local $returnvalue = _StringBetween($HTML[1], 'value="', '"')
			If @error Then
				Return SetError(3, 0, 0)
			Else
				;If UBound($returnvalue) < 9	Then
					;Return False
				;Else
					Local $value0 = $returnvalue[0] ;
					Local $value7 = $returnvalue[7] ;0
					Local $value8 = $returnvalue[8] ;1
					Local $HTML2 = _WinHttpSimpleSSLRequest($startttttttt, "POST", "/login.php?m=m&refsrc=http%3A%2F%2Fm.facebook.com%2F&refid=8", "m.facebook.com", "lsd=&charset_test=" & $value0 & "&version=1&ajax=1&width=1680&pxr=1&gps=1&email=" & $Email & "&pass=" & $Password & "&m_ts=" & $value7 & "&li=" & $value8, Default, 1)
					If @error Then
						Return SetError(4, 0, 0)
					Else
						FileWrite("logged in.html", $HTML2[1])


							Local $get_group = _WinHttpSimpleSSLRequest($startttttttt, "GET", "/groups/" & $target_group, Default, Default, Default, 1)
	FileWrite('group_page.html',$get_group[1])
	$fb_dtsg = StringRegExp($get_group[1], 'name="fb_dtsg" value="(.+?)"', 3)
	FileWrite('$fb_dtsg.txt',$fb_dtsg[0])
	$charset_test = '%E2%82%AC%2C%C2%B4%2C%E2%82%AC%2C%C2%B4%2C%E6%B0%B4%2C%D0%94%2C%D0%84'

	Local $click_photos_add = _WinHttpSimpleSSLRequest($startttttttt, "POST", "/composer/mbasic/?av=" & $profile_id & "&refid=18", 'https://m.facebook.com/groups/' & $target_group, 'fb_dtsg=' & $fb_dtsg[0] & '&charset_test=' & $charset_test & '&target=' & $target_group & '&c_src=group&cwevent=composer_entry&referrer=group&ctype=inline&cver=amber&rst_icv=&xc_message=&view_photo=Add+Photos', Default, True, 1)
	FileWrite('after click.html', $click_photos_add[1])
$csid = StringRegExp($click_photos_add[1], 'csid=(.+?)&amp', 3)
$fb_dtsg2 = StringRegExp($click_photos_add[1], 'name="fb_dtsg" value="(.+?)"', 3)
FileWrite('$csid.txt', $csid[0])

$boundary = 'FsBAkcQpOwiNzKNS'

Local $sHead = ''
$sHead &= 'accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8' & @CRLF
$sHead &= 'accept-encoding: gzip, deflate' & @CRLF
$sHead &= 'accept-language: en-US,en;q=0.8' & @CRLF
$sHead &= 'cache-control: max-age=0'
;$sHead &= 'content-length: 196162'
$sHead &= 'content-type: multipart/form-data; boundary=----WebKitFormBoundary' & $boundary & @CRLF ;BOUNDARYYYY!!!!

$sHead &= 'origin: https://m.facebook.com' & @CRLF
$sHead &= 'referer:https://m.facebook.com/composer/mbasic/?mnt_query&csid=' & $csid[0] & '&ctype=inline&errcode=0&cwevent=composer_entry&tag_friends_query&filter_type=0&av=' & $profile_id & '&rst_icv&icv&ogi_offset=0&ogi_limit=0&lat&lon&pos&x-acc=0&view_photo&_rdr' & @CRLF
$sHead &= 'upgrade-insecure-requests: 1' & @CRLF
;user-agent:Mozilla/5.0 (Windows NT 6.1; rv:42.0) Gecko/20100101 Firefox/43.0


Local $sData = ''
$sData &= '------WebKitFormBoundary' & $boundary & @CRLF
$sData &= 'Content-Disposition: form-data; name="fb_dtsg"' & @CRLF & @CRLF

$sData &= $fb_dtsg2[0] & @CRLF
$sData &= '------WebKitFormBoundary' & $boundary & @CRLF
$sData &= 'Content-Disposition: form-data; name="charset_test"' & @CRLF & @CRLF

$sData &= $charset_test & @CRLF
$sData &= '------WebKitFormBoundary' & $boundary & @CRLF
$sData &= 'Content-Disposition: form-data; name="file1"; filename="its too easy 1.jpg"' & @CRLF
$sData &= 'Content-Type: image/jpeg' & @CRLF & @CRLF & @CRLF


$sData &= '------WebKitFormBoundary' & $boundary & @CRLF
$sData &= 'Content-Disposition: form-data; name="file2"; filename="its too easy 2.jpg"' & @CRLF
$sData &= 'Content-Type: image/jpeg' & @CRLF & @CRLF & @CRLF


$sData &= '------WebKitFormBoundary' & $boundary & @CRLF
$sData &= 'Content-Disposition: form-data; name="file3"; filename="its too easy 3.jpg"' & @CRLF
$sData &= 'Content-Type: image/jpeg' & @CRLF & @CRLF & @CRLF


$sData &= '------WebKitFormBoundary' & $boundary & @CRLF
$sData &= 'Content-Disposition: form-data; name="add_photo_done"' & @CRLF & @CRLF

$sData &= 'Preview' & @CRLF
$sData &= '------WebKitFormBoundary' & $boundary & @CRLF
$sData &= 'Content-Disposition: form-data; name="filter_type"' & @CRLF & @CRLF

$sData &= '5' & @CRLF
$sData &= '------WebKitFormBoundary' & $boundary & @CRLF
$sData &= 'Content-Disposition: form-data; name="target_id"' & @CRLF & @CRLF

$sData &= $target_group & @CRLF
$sData &= '------WebKitFormBoundary' & $boundary & @CRLF
$sData &= 'Content-Disposition: form-data; name="waterfall_source"' & @CRLF & @CRLF

$sData &= 'composer_group' & @CRLF
$sData &= '------WebKitFormBoundary' & $boundary & @CRLF
$sData &= 'Content-Disposition: form-data; name="waterfall_id"' & @CRLF & @CRLF

$sData &= $csid[0] & @CRLF
$sData &= '------WebKitFormBoundary' & $boundary & @CRLF
$sData &= 'Content-Disposition: form-data; name="waterfall_app_name"' & @CRLF & @CRLF

$sData &= 'web_m_basic' & @CRLF
$sData &= '------WebKitFormBoundary' & $boundary & '--' & @CRLF


Local $photos_preview = _WinHttpSimpleSSLRequest($startttttttt, "POST", '/composer/mbasic/?csid=' & $csid[0] & '&av=' & $profile_id & '&view_overview', 'https://m.facebook.com/composer/mbasic/?mnt_query&csid=' & $csid[0] & '&ctype=inline&errcode=0&cwevent=composer_entry&tag_friends_query&filter_type=0&av=' & $profile_id & '&rst_icv&icv&ogi_offset=0&ogi_limit=0&lat&lon&pos&x-acc=0&view_photo&_rdr', $sData, $sHead, True, 1)
FileWrite('preview.html', $photos_preview[1])
Local $photos_preview2 = _WinHttpSimpleSSLRequest($startttttttt, "GET", '/composer/mbasic/?csid=' & $csid[0] & '&view_overview&av=' & $profile_id & '&_rdr', 'https://m.facebook.com/composer/mbasic/?mnt_query&csid=' & $csid[0] & '&ctype=inline&errcode=0&cwevent=composer_entry&tag_friends_query&filter_type=0&av=' & $profile_id & '&rst_icv&icv&ogi_offset=0&ogi_limit=0&lat&lon&pos&x-acc=0&view_photo&_rdr', Default, Default, 1)
FileWrite('previewssssssss.html', $photos_preview2[1])
					EndIf
				;EndIf
			EndIf
		EndIf
	EndIf
EndFunc

_FBLogout($startttttttt, $login)

Func _FBLogout($FBStart, $FBLogin)
	Local $FBHome = _WinHttpSimpleSSLRequest($FBStart, 'GET')
	If @error Then
		Return SetError(1, 0, 0)
	Else
		Local $Logout = StringRegExp($FBHome, '<a class=".+?" href="(/logout.php.+?)">Logout', 3)
		If @error Then
			Return SetError(2, 0, 0)
		Else
			Local $HTML3 = _WinHttpSimpleSSLRequest($FBStart, 'GET', $Logout[0])
			If @error Then
				Return SetError(3, 0, 0)
			Else
				Return 1
			EndIf
		EndIf
	EndIf
	;;;;;;;;;;;FileWrite("logged out.html", $HTML3[1])
EndFunc


Застрял на шаге, где должен получить страницу с Preview картинок, это значит, что запрос передается не правильно либо я ответ получаю не так наверное
У кого какие идеи, напутствия? :beer:
Загаловки брал из Chromium Developer tools, подменяя User-agent на firefox-ный
 
Верх